skip to Main Content

I know there is many solutions given regarding the same question but I tried all of them and none of them working at all.

I am tried following ways but none of them worked. My php version is 7.1 and Codeigniter framework I am using.

By setting header in index.php

header('Set-Cookie: HttpOnly; SameSite=None;Secure');

By setting in .htaccess

Header edit Set-Cookie ^(.*)$ "$1;HttpOnly;Secure;SameSite=none"

By setting in apache2 httpd.conf

Header edit Set-Cookie ^(.*)$ "$1;HttpOnly;Secure;SameSite=None"

I have reviewed Chrmoe git updates, it says
header('Set-Cookie: cross-site-cookie=bar; SameSite=None; Secure');

I didn’t get the option cross-site-cookie=bar. What will be value for it.

I also tried the same one but it didn’t work at all.

4

Answers


  1. Chosen as BEST ANSWER

    Hello I have solved this issue by following. Hope it will help to others

    In httpd.conf (For bitnami server file will be /opt/bitnami/apache2/conf)

    Header always edit Set-Cookie ^(.*)$ $1;Secure;SameSite=None
    

  2. This might also help for someone still struggling, and using PHP >= 7.3.x and using CI 3.1.11

    In the index.php found in the root, add the code below <?php

    if(isset($_COOKIE["PHPSESSID"])){
        header('Set-Cookie: PHPSESSID='.$_COOKIE["PHPSESSID"].'; SameSite=None');
    }
    

    It worked for me, after trying it all (in vain)

    Login or Signup to reply.
  3. Paste the code below in your .htaccess file

    <If "%{HTTP_USER_AGENT} !~ /(iPhone; CPU iPhone OS 1[0-4]|iPad; CPU OS 1[0-4]|iPod touch; CPU iPhone OS 1[0-4]|Macintosh; Intel Mac OS X.*Versionx2F1[0-3].*Safari|Macintosh;.*Mac OS X 10_14.* AppleWebKit.*Versionx2F1[0-3].*Safari)/i">
        Header edit Set-Cookie ^(.*)$ $1;SameSite=None;Secure
    </If>
    
    Login or Signup to reply.
  4. This worked for me:

    sudo nvim /etc/apache2/conf-available/security.conf

    Header set Set-Cookie "mycookie=myvalue; Domain=mydomain.com; Path=/; Secure; HttpOnly; SameSite=Strict"

    sudo systemctl restart apache2

    Header set Set-Cookie

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search