Code: Select all
<?php
session_start();
header("Cache-control: private");
error_reporting(E_ALL);
if(isset($HTTP_POST_VARS['submit'])){
if((strlen($HTTP_POST_VARS['username']) > 0) && (strlen($HTTP_POST_VARS['password']) > 0)){
$username = $HTTP_POST_VARS['username'];
$password = $HTTP_POST_VARS['password'];
require_once ("../../w/connect.inc");//einai sto music.hxotpon.net/blabla.php
$query = "SELECT * FROM customers WHERE username='$username'";
$query_result = mysql_query ($query);
$check = mysql_num_rows($query_result);
if($check > 0)
{
$a = 0;
$row = mysql_fetch_array($query_result);
if(($row['username'] == $username) && ($row['password'] == $password))
{
$logged_in = TRUE;
$login_status = TRUE;//user authenticated
$id_customer = $row['id_customer'];//prepei na kseroume poios ekane login
$_SESSION['logged_in'] = TRUE;
$_SESSION['id_customer'] = $id_customer;
} else {
$_SESSION['logged_in'] = FALSE;//wrong password
$login_status = FALSE;
}
if($_SESSION['logged_in'])
{
//$_SESSION['session_id'] = 0;
$rand = rand(1,9);
$session_id=$rand.substr(md5($REMOTE_ADDR), 0, 11+$rand);
$session_id.=substr(md5(rand(1,1000000)), rand(1,32-$rand), 21-$rand);
session_id($session_id);
$_SESSION['session_id'] = $session_id;
echo '<font color="green"> Σωστό password </font>';
echo $session_id;
} else {
echo '<font color="red"> Wrong password</font>';
}
} else {
echo '<b><font color="red"> Try Again </font></b>';
}//telos if($query_result)
mysql_close();
} else {
echo '<font color="red">You left empty one of the fields!</font>';
}//telos if(strlen...
}
?><td><div align=center><strong>
Code: Select all
<?php
if($_SESSION['logged_in']){//ekteleitai kai auto
echo'<span class=style4>Ευχαριστούμε που συνδεθήκατε στο</span>
<span class=style2>HXOTPON</span>';}else{
echo'<meta http-equiv="Refresh" content="0;url=http://xxx/index.php">';
}
?><a href="index.php">clidk</a>
to continue</span></strong></div></td>
All the functions work properly and i can echo the $_SESSION variables easily in this page (e.g. login.php) but when i return back to index.php i can't recover any $_SESSION variable!
In index.php i use the code:
Code: Select all
<?php
session_start();
header("Cache-control: private");
echo $_SESSION['logged_in'];
echo $_SESSION['id_customer'];
?>....html and php code..
but i can't use the $_SESSION variables!(NO echo!)
Any idea about that problem??