How can we keep session value when user cookies are deleted?
<?php
session_start();
echo $_SESSION['userdata']['name']='bikash';
?>
If user deletes the cookies, my session value has deleted. Please advise.
As other posters have mentioned the cookies contains the session id which is required to access the session. However unless you perform a session_destroy()
the actual session data can be still found on the directory which session files are stored.
Because the session ID is stored in a cookie. If the user deletes it, then you can't recover it.
Once cookie is deleted, session ID is deleted as well as it's in that cookie. There's no way to get session ID if cookie is deleted as per my knowledge
The session ID it self is stored in a cookie.
If the user deletes it, then you cant access any information associated with the session because there's no way of referring to it.
In other words, you delete the browser cookies, the session is deleted since the session is stored as a cookie!
As rid already said, the session identifier is stored within a cookie for every user. So when they delete their cookies, the session identifier is also gone, making it impossible for session_start
to relaunch the previous session. Instead it will start a new one, with no data.
If you have some other means of assigning a previous session to a user, for example if you have a database that maps ip addresses to session ids (bad idea!), then you could restore the previous session id using session_id()
.
You can't recover sessoin id if cookie is deleted as it's in cookie.