I have many projects running on my server all of which use PHP sessions for authentication.
Now since the PHPSESSID cookie sets the cookie path to '/' in the set-cookie header, this cookie is available throughout the domain, whereas I need it available only to the current application.
Because of this, the following problem occurs :
A user who is logged into mysite.com/application-1 automatically gets logged into
..etc
So, How do I set the path of the PHPSESSID cookie ?
By default the session cookie get created with the current path until you change it to save cookie on any other path or '/'
.
You may tell your script to save session cookie on the project specific directory. You can use the session_set_cookie_params for this. This must be called before the session_start()
session_set_cookie_params(0,'/dirname');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With