robcrozier Posted April 9, 2009 Share Posted April 9, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/153284-session/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.