I am trouble with session; I know it theoretically but I encountered with it how to use session , transferring username to
After the line
$result=mysql_query($sql);
add
if ($data = mysql_fetch_array($result)) {
$_SESSION['user'] = $data['usermail'];
}
Now session created.Call this session in jcte/index.php page as:
<?php
session_start();
echo "welcome $_SESSION['user']";
?>
Unset the session in logout.php page as:
<?php
session_start();
unset($_SESSION['user']);
?>
<?php
session_start();
$_SESSION['user']="Varma"; //intializing the session['user'];
echo $_SESSION['user']; // displaying the data
unset($_SESSION['user']); // destroying the session data.
?>
but you have to initialize session_start();
in all web pages where you have need to access that session variables.
Always start session page with session_start().
If you want to use session first assign session a value like this :
session_start();
$_SESSION['username'] = 'Mahmood';
And when you want to access get it like this :
echo $_SESSION['username'];
OR
$username = $_SESSION['username'];
And unset this session like this :
unset($_SESSION['username']);
Some Details are here.