PHP Session Variables Not Being Maintaned

PHP session variables not being maintaned

My suggestion from your previous question still stands: please compare session ids.

The solution might be as simple as your browser not accepting session cookies.

You retrieve the session id by calling session_id(). Do that right after session_start() it should give you a constant value if the session is the same. Otherwise for every request a new session is instantiated.

Also check C:\wamp\tmp. A gazillion files in this directory might indicate fresh sessions for each request.

EDIT Since we've confirmed new sessions per request, it's time to find out whether session cookies are accepted. Check the settings of your browser and confirm that a cookie for your domain (I guess it's "localhost") with the name PHPSESSID can be found.

PHP Session Variables Not Preserved

The session ID has to be carried along in some way in order that the same session can be used over several pages. In general this is done with a cookie (see session.use_cookies) but it can also be done in the URL or in forms (see session.use_trans_sid).

So first you have to make sure that the session ID is transmitted so that PHP can load the right session and session data.

See also Is my understanding of PHP sessions correct?

Session variables are not persisting between page loads

The answer to this is it was a hosting configuration error. Hosting company changed something and it has worked ever since.

PHP $_SESSION variables not holding

<a class="links" href="<?php session_destroy(); header("Location:index.php");?>">Log Out</a>

This is not creating a link to this code, you're actually running it! Create a logout.php page with this code in it, and link to that page instead. This is why your session is being destroyed. You also need session_start() on all pages that use sessions.



Related Topics



Leave a reply



Submit