problem in login using sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dumbledore
Forum Newbie
Posts: 2
Joined: Thu Oct 08, 2009 7:08 am

problem in login using sessions

Post by dumbledore »

I am creating a user login using php where in i have to enforce user to change his/her passwd if its their first login.I have used a first_login_flag in the mysql database for this purpose.when user logs in, first_login_flag is set to 'N'.now the problem is that it works fine for the first user. but when i try to log in as the second user, it takes the old session values. and takes the first_login_flag as 'N'. this is wrong as this is the first login for this second user.please help me using the sessions. thanks.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: problem in login using sessions

Post by jackpf »

You should completely destroy the session on logout.
dumbledore
Forum Newbie
Posts: 2
Joined: Thu Oct 08, 2009 7:08 am

Re: problem in login using sessions

Post by dumbledore »

Thanks. Actually i am really new in php and dont know anything about sessions. could you help me out with the code.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: problem in login using sessions

Post by Eric! »

User avatar
desperado
Forum Commoner
Posts: 46
Joined: Wed Dec 10, 2008 8:49 am

Re: problem in login using sessions

Post by desperado »

Think of a session as "This browser window is open right now, and I'm browsing on the server."

If you log out as one user and log-in as another user (same browser, same window) the server will consider it to be the same session.

Either close your browser window, or quit the browser to close your session.

if you destroy the session on log out within your php code, then you avoid this problem altogether.
Post Reply