i created sessions for my page...but i want to store session data so that when the user logs out from a page,and when he logs back he can start from where he stopped
This is what i have done so far
login_processor
<?php session_start();
// Developed by Roshan Bhattarai
// Visit [
roshanbh.com.np...] for this script and more.
// This notice MUST stay intact for legal use
//Connect to database from here
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
//select the database | Change the name of database from here
mysql_select_db('healthreg');
//get the posted values
$user_name=htmlspecialchars($_POST['user_name'],ENT_QUOTES);
$pass=md5($_POST['password']);
//now validating the username and password
$sql="SELECT * FROM members WHERE user_name='".$user_name."'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
//if username exists
if(mysql_num_rows($result)>0)
{
//compare the password
if(strcmp($row['password'],$pass)==0)
{
echo "yes";
$member = mysql_fetch_assoc($result);
//now set the session from here if needed
$_SESSION['u_name']=$user_name;
//$_COOKIE['u_name']=$user_name;
$_COOKIE['SESS_MEMBER_ID'] = $member['member_id'];
}
else
echo "no";
}
else
echo "no"; //Invalid Login
?>
<!--Session check on every page except login page-->
<?php
//Start session
session_start();
// setcookie($_COOKIE['SESS_MEMBER_ID']);
//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['u_name']) || (trim($_SESSION['u_name']) == '')) {
echo "not picking session";
if (isset($_COOKIE['SESS_MEMBER_ID']) && isset($_COOKIE['SESS_MEMBER_ID'])) {
echo "Success";
} else {
echo "Failed";
}
exit();
}
?>
<!--logout-->
<?php
//Start session
session_start();
//Unset the variables stored in session
unset($_SESSION['u_name']);
?>