Hi all, I'm developing a database system on my local computer (OS/version details at bottom) with a simple user authentication using sessions. On a successful login, the previous login time is stored in the $_SESSION array and the new one is inserted into the database. A welcome message is then displayed, below which the previous login time should be printed, after which the variable is deleted.
Yet, PHP seems to delete the variable prior to printing it on the screen, resulting in the absence of the previous login time, although the command to delete it from the array is issued AFTER the print () command. When I refrain from deleting the variable from the SESSION array, the previous login time is printed just like it should be. Anyone seen this before and/or knows what to do? When I don't delete the variable, it keeps displaying it everytime. This is my code : ----- session_start(); ... $_SESSION[auth] = mysql_fetch_array(mysql_query("SELECT * FROM user WHERE user = \"$_POST[username]\" AND pass = \"".md5($_POST[password])."\"")); $auth = $_SESSION[auth]; $_SESSION['last_logn'] = $auth['last_logn']; if (!$auth) { ... //not logged in } else { mysql_query("UPDATE user SET last_logn = NOW() WHERE nr = $auth[nr]"); ...//redirect to index using header() } ... //index blah blah welcome etc. if ($_SESSION['last_logn']) { print (" <B>Last login : ".$_SESSION['last_logn']."</B><BR>\n"); $_SESSION['last_logn'] = ""; } ----- So, you might think this will display the welcome message with the last login time below it. No, it doesn't. When I quote the line '$_SESSION['last_logn'] = "";' it does display, but then it keeps doing that until you log off. Not so elagant. Any ideas/suggestions??? Thank you in advance! Ivo -- [Win2000 | Apache/1.3.23] [PHP/4.2.3 | MySQL/3.23.53] Ivo Fokkema PHP & MySQL programmer Leiden University Medical Centre Netherlands -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php