RE: [PHP] @session_start generates a new session_id
| From: | Lizet Peña de Sola | Date: | Wed, 27 Oct 2004 21:26:26 +0000 |
| Subject: | RE: [PHP] @session_start generates a new session_id | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-200478@lists.php.net to get a copy of this message | ||
session_id($username);
session_start();
Solved the problem...
Thank you all for the replies...
-----Original Message-----
From: Lizet Peña de Sola [mailto:lizet@krosslink.com]
Sent: Wednesday, October 27, 2004 3:55 PM
To: rv@domos.be; php-general@lists.php.net
Subject: RE: [PHP] @session_start generates a new session_id
It still doesn't work :(... When I try to destroy the session without asking
if there's a session_id, it gives me a warning, I fixed it with the
if(session_id()) but still, when the user logs in again with a different
profile, in the same browser window, the profile that is loaded is the
previous one... Here I copy the logout.php code: <?
$_SESSION['validlogin']="";
$_SESSION['username']="";
$_SESSION['password']=""; //destroy the sessions array
$_SESSION = array();
//destroy the session
if(session_id()){
session_destroy();
}
?>
And the code that runs when the user logs in:
<?
$username=trim($_POST['user']);
$password=trim($_POST['pwd']);
if(session_id()){echo('Error, please contact tech support'); exit();}
if(validateuser()){
session_start();
$_SESSION['validlogin']=true;
$_SESSION['username']=$username;
$_SESSION['password']=$password;
}
...
?>
Any ideas why the session variables get set to their first value after
starting the session for the second time? Should I create a different
session id each time? Tia, Lizet
-----Original Message-----
From: Reinhart Viane [mailto:rv@domos.be]
Sent: Tuesday, October 26, 2004 12:49 PM
To: 'Lizet Peña de Sola'; php-general@lists.php.net
Subject: RE: [PHP] @session_start generates a new session_id
Instead of:
<? $_SESSION['validlogin']=""; $_SESSION['username']="";
$_SESSION['password']=""; unset($_SESSION['validlogin']);
unset($_SESSION['username']); unset($_SESSION['password']);
session_unset(); print("username=".$_SESSION ['username']);
print("password=".$_SESSION['password']);
if(session_id()){
session_destroy();}
?>
Try this:
//unregister the sessions
$_SESSION['validlogin']=""; $_SESSION['username']="";
$_SESSION['password']=""; //destroy the sessions array $_SESSION = array();
//destroy the session
session_destroy();
Greetings
Reinhart Viane
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php