Web Hosting Talk







View Full Version : PHP Sessions!! Why can't they get along??


jtrovato
11-04-2002, 11:20 PM
I have created a site wher user are required to login.

It checks the MySQL database and of course if user is aloud to enter, they may.


Once they are in and when they are finished they close the browser, on certain version of 98 and IE the session is still active.

Now that is fine b/c when you open a new browser it creates a new session but not in the case on 98/IE. It has the same session ID number, I have to destory the session in order for me to create a new one.

is there anyway around this?

it seems to only happen on windows 98.. it seems to work with 2000 pro /xp with any problems

John

MarkIL
11-05-2002, 01:07 AM
Make sure you set the session timeout to a reasonable value.
You could also request that the users explicitly click on a "Log out" link, which will call session_destroy() and end the session.

ChickenSteak
11-05-2002, 01:09 AM
Or you could make it so when a session is duplicated, you can destroy all headers on that session a little more complicated then lewney's way.

debug
11-05-2002, 08:26 AM
Managing Users with PHP Sessions and MySQL: http://www.webmasterbase.com/article.php?pid=0&aid=319

jtrovato
11-05-2002, 11:20 AM
ChickenSteak,

You gave me a great idea, thanks.

What was happening was once a user logged into the site, and closed the browser. If they went back to the site it would say that they were already logged in.

So now what I did was checked to see if the session was this active and destroyed it if they went to the home page. I personality don't think this is a good idea b/c they could still go directly to a full url link and edit and change things after the user got up and walked away.

I also have a logout link on the top of every page. If they logout there will be little/no problems

John

silversurfer
11-06-2002, 01:13 AM
maybe one of the session is male and the other is female.... bad humour aside, setting a reasonable timeout value will help. Also make sure you disable caching. Sometimes that causes people to think they have a problem.