Jump to content

Recommended Posts

Hi everyone.

I'm looking for a way to create completely unique PHP sessions on a shared server where by default, the session save path is the same for all users.  At present, this means that if i create a session like this:

 


$_SESSION['username'];

 

to store a users username when they are logged in, the next visotor also gets a session called 'username' assigned to them and stored in the same place on the server.  This is causing some people to get logged out prematurely etc.  It seems like the session data is either getting overwritten on the server and two users are sharing the same session id, or sessions are getting confused between instances.

 

Can anyone suggest how they use and store sessions and if you have ever come accross this problem before.  The way i'm getting around it at the minute is to create a random ID (again stored in a session) when the page is loaded and this gets tagged onto the start of a session like so:

 


$randomId = rand();
$_SESSION[$randomId.'username'];

 

This doesn't seem like the most efficient methos however.

 

Any help / advice would be great!

Link to comment
https://forums.phpfreaks.com/topic/153284-session/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.