HELP : Session value overwirting each another ?

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
adisonz
Forum Newbie
Posts: 11
Joined: Wed Feb 08, 2006 2:09 am

HELP : Session value overwirting each another ?

Post by adisonz »

when i browse the same page with different user id ,

the frist logged in user id will overlaped by the last loged in id ,

Code: Select all

$_SESSION['username'] = $_POST['username'];
this code will run when a sucessfull login ,

but when 2 successfull login will overwirte the frist value ,


plz help , any solution ?
User avatar
ambivalent
Forum Contributor
Posts: 173
Joined: Thu Apr 14, 2005 8:58 pm
Location: Toronto, ON

Post by ambivalent »

If you're doing this from the same browser and machine, the session id is still the same from PHP's point of view because the browser is sending the same cookie (assuming default settings). It should work as expected if you destroy the session of user 1. You may have to delete the session cookie as well, before attempting the second login.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

You can use session_unregister() to unregister the variable on the logout page.

Code: Select all

session_unregister('username');
adisonz
Forum Newbie
Posts: 11
Joined: Wed Feb 08, 2006 2:09 am

erm...yah ...i use session destroy ...but ..

Post by adisonz »

erm...yah ...i use session destroy ...but ..i need to demostrate to my tutor , that different user at one time ,

so i need to open 2 browser and both login ,


...any idea ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yes, two different browsers.
Post Reply