Welcome Guest, Not a member yet? Register   Sign In
CSRF $csrfProtection set to cookie keeps regenerating
#3

(This post was last modified: 03-06-2022, 07:01 AM by GGitzOle.)

Thanks for your reply.

I just installed a fresh CI 4.1.9 framework and I still can't get cookies to work. Are there any default settings needed to get it work? I'm using a subdomain like dev.mysite.com but not sure if that affecs it.

PHP Code:
setcookie("TestCookie"123time()+3600);
        
// Using the constructor
        
$cookie = new Cookie(
            
'remember_token',
            
'f699c7fd18a8e082d0228932f3acd40e1ef5ef92efcedda32842a211d62f0aa6',
            [
                
'expires'  => new DateTime('+2 hours'),
                
'prefix'   => '__Secure-',
                
'path'     => '/',
                
'domain'   => '',
                
'secure'   => true,
                
'httponly' => true,
                
'raw'      => false,
                
'samesite' => Cookie::SAMESITE_LAX,
            ]
        );

        echo 
$cookie->getName(); // 'remember_token'


        
echo "Cookie Test";

        exit(); 


The TestCookie works and is set using PHP's native setcookie function. Trying to use the CodeIgniter Cookie Class and it doesn't do anything.

When echo $cookie->getName() it shows "remember_token" so the data being passed seems fine.

Not sure if there is an issue on my server that is causing this conflict. I've tried looking at the system/Cookie/Cookie.php file to see how it works but I'm too inexperienced to follow the path and figure out what is causing it.

Any help on where to look next for debugging it?
Reply


Messages In This Thread
RE: CSRF $csrfProtection set to cookie keeps regenerating - by GGitzOle - 03-06-2022, 06:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB