PHP session variables went away when clearing cookies

I've done a lot of research on the internet regarding sessions and cookies, and the argument for sessions that I keep coming across is that if cookies are disabled it won't affect sessions.

However, every time an explicit cookie is made, my session variables seem to be cleared as well. Also, I have read several websites that should actually be read using cookies.

Can someone please explain this to me?

+3


source to share


5 answers


If its possible php stores its session id in a cookie. If your browser rejects this, it carries the session id along with the query string.

If you kill your cookies and don't customize the query string php will forget who you are!



However, the use of cookies can be disabled http://de2.php.net/manual/en/session.configuration.php#ini.session.use-cookies

+5


source


You are wrong. sessions depend on cookies. when you request a page, a cookie is sent to the server containing your session id. so clearing the cookies will result in the loss of the session.



0


source


You can force PHP SESS ID in get instead of cookie if you like, default is cookie

0


source


The session uses cookies by storing a cookie with an expiration date of the nearest (or sometimes even negative) date. In PHP, this cookie can be found by PHPSESSID

its default name . Using a function session_start

in PHP is required at runtime to load, associate / authenticate a user and associated session information.

Since sessions are a special type of cookie clearing (even if cookies are disabled), it will most likely result in the loss of the session ID, causing the session to be reset.

This is a great article that clears up any mystery behind PHP sessions:

http://justinmccormick.com/wp/programming/php-sessions-explained

0


source


PHP stores the session id inside the default cookie if you clear the session.

What you can do is enable session.use_trans_sid . So PHP adds the session id to the url. (but I would not recommend this)

0


source







All Articles