UPDATE ON THE PROBLEM:
- On some browsers, we have two PHPSESSIDs.
- One PHPSESSID is not set by me anywhere in my script
- It has HOST (instead of DOMAIN for the PHPSESSID I set) as www.mywebsite.com
- I have tried deleting it using setcookie:
setcookie ("PHPSESSID", $_COOKIE['PHPSESSID'], time() - 864000, '/', 'www.mywebsite.com');
but this fails. - An attempt to delete cookie using:
setcookie ("PHPSESSID", $_COOKIE['PHPSESSID'], time() - 864000, '/');
results in the PHPSESSID I set being deleted. - I have tried using
session_name
to rename the SESSION I set. This works but crashed my server severally after some minutes. - I am out of options.
I am working with PHP sessions on my website.
The session path was /folder, later on I changed to / to fit the new purpose.
Now, old users cant login.
It seems they now have two PHPSESSIDs stored on their browsers - one with path /folder and the other /.
What can I do to ensure that old users can login while ensuring that the session is sitewide with "/".
MORE INFORMATION
When I said two phpsessionid, refer to the image
- The login works if I use
A. session_set_cookie_params(864000, '/cv', '.website.com', 0, 1);
but fails to work if I use:
B. session_set_cookie_params(864000, '/', '.website.com', 0, 1);
- If I use Version 2A above, the session will only be available in /cv and not be available in other website folders eg. /folder.
UPDATE ON DELETING PHPSESSID WITH JAVASCRIPT
- When I run alert(document.cookie), it shows all cookies except the PHPSESSID
- Hence all attempts to delete the PHPSESSID cookie fails, whereas other cookies can be deleted.
UPDATE ON DELETING PHPSESSID WITH PHP
- When I
var_dump($_COOKIE['PHPSESSID']);
what is returned is the value of the PHPSESSID with path /cv - An attempt to delete with
setcookie ("PHPSESSID", "", time() - 3600);
fails.
session.savepath
, etc), so the standard session data in/cv
can be manually saved in/
with an include for instance, but this is a big hassle for something that you should just let people re-login, as their sessions will expire when their browser closes anyway.... they're not the same as cookies – Corm$_SESSION
data belong to this client. Since you now configured your PHP to use a cookie with/
path, I believe the cookie with/cv
path should get deliberately ignored. Even if not, you can simply unset it if it's present. It should then never again be created. – Vehemence$_SESSION = array(); session_destroy();
not affect it? – Intensifystart_session();
in my website which stores a cookie called PHPSESSID with the value being some hxadecimal number. This cookie is readable by JS (my self-made cookie editor can show it) but any attempt to change it just creates a second one with the same name which has the changes, so when trying to expire it it there's effectively no change. Is that the same problem you have? Also, I can't find PHPSESSID in cookies.sqlite in my Firefox profile, so I have literally no clue how to get rid of it. – Saturninasaturnine