Changing Session cookie - samesite v4.6.1 |
Hi all,
Using v4.6.1 - in app/Config/Cookie.php - after changing samesite setting to 'None' PHP Code: public string $samesite = 'None'; Console error is: Quote:Cookie “pm_id” has been rejected because it is in a cross-site context ... Still get cross-site errors. I'm doing this for testing, connecting to the remote CI4 server from localhost on local machine. I've tried using Cookie helper to no avail-: PHP Code: helper('cookie'); Is it possible to force samesite to 'None' for the CI session cookie? Many thanks, Mike
Just to confirm, are you the one setting up the cookie named "pm_id"? From your example, it seems the name is "session_id".
(05-17-2025, 01:45 PM)codeus Wrote:(05-17-2025, 08:09 AM)paulbalandan Wrote: Just to confirm, are you the one setting up the cookie named "pm_id"? From your example, it seems the name is "session_id". Confirmed: whether using 'session_id', or 'pm_id', the issue remains the same. I believe this is a bug. Any setting in Cookie $samesite appears to be overridden by the default Lax setting.
No, samesite is only changed to Lax if the passed $samesite is an empty string. Can you show your code that sets up the session cookie?
(Yesterday, 07:41 AM)paulbalandan Wrote: No, samesite is only changed to Lax if the passed $samesite is an empty string. Can you show your code that sets up the session cookie? PHP Code: class Cookie extends BaseConfig app/Controllers/BaseController.php PHP Code: public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger): void
You should check to see if your sessions are running.
PHP Code: // E.g.: $this->session = service('session'); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(Yesterday, 09:36 PM)InsiteFX Wrote: You should check to see if your sessions are running. PHP Code: vendor/codeigniter4/framework/system/Session/Session.php [/php]
This should help you understand how it's working, there are a couple other articles in this one.
SameSite cookies explained What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(7 hours ago)InsiteFX Wrote: This should help you understand how it's working, there are a couple other articles in this one. My issue is, how do I set a session to use samesite 'None' ? Other than using a hack.
That's weird. On where you put the hack, can you put these lines so we can debug the values?
dd($this->cookie->getSameSite()); dd(config(\Config\Cookie::class)->samesite); Make sure to remove first your temporary hack then run your code again. You should see the values for the lines above and paste them here. |
Welcome Guest, Not a member yet? Register Sign In |