PDA

View Full Version : PHP Sessions



boxxertrumps
01-11-2007, 01:18 AM
Hey Guys...
Im Working On Multiple projects at once With My Server.
this Evening I made an entire set of login/register scripts with encrypted passwords. and i Have a Question About Sessions.
heres My logon Script... Fell Free to Point out Any Flaws.
But What im Trying to do is create A script to destroy the sessions and log out.

<?php require "connect.php"
echo 'Loging on.\n\r';
$user = $_POST[post_user];
$password = md5($_POST[post_pass]);

$userInfo = mysql_query("SELECT * FROM `login` where `user`=`user-$user-`");
if (!mysql_num_rows($userInfo)) {echo 'No such user!';}
else {
$q = mysql_fetch_array($userInfo);
if ($password != $q[password]) {echo 'wrong password';}
else {
session_start();
$_SESSION['user'] = $user ;
$_SESSION['pass'] = $password];
$_SESSION['time'] = time();
header("Location: $welcome_page");
};
};
?>
The $welcome_page and mysql connect are in connect.php

thanks in advance.

Never Mind. decided to just null the values instead of destroying the sessions.


<?php require "connect.php"
$_SESSION['user'] = "";
$_SESSION['pass'] = "";
echo "You have been Logged In For ". time() - $_SESSION['time'] ." Seconds. /n/r
<a href=\"$logout_to_page\">Continue.</a>" ;
$_SESSION['time'] = ""
?>