Have you tried to print_r($_SESSION) on all the pages so that you can see
what the $_SESSION is containing and how it is changing?

Best regards,

Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free



-----Original Message-----
From: Ashish Rizal [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 20, 2007 12:26 AM
To: php-general@lists.php.net
Subject: [PHP] Poblem with sesions

Hi , I am having problem with log in and log out . I have a main
login page where one can login with the username and password
stored in mysql database.
PHP Code:

<?php
session_start();
//ob_start();
require_once 'functions.php';
$UserName = $_POST['UserName'];
$Password = $_POST['Password'];
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$adminAddress = getAbsolutePath().'adminlogin.php';
$userAddress = getAbsolutePath().'userlogin.php';
$samePage = getAbsolutePath().'login.php';
if ($_POST){
$error = login_check($_POST);
if (trim ($error)=="")
{
$accesslevel = accessLevel($UserName);
?>
<?php
if ($accesslevel == "admin"){
$_SESSION['level'] = "admin";
$_SESSION['username'] = $_POST['UserName'];
$_SESSION["userid"] = login($_POST);
include ('adminlogin.php');
//echo "<script language='javascript'>
location.href='$adminAddress'; 
exit();
}
else if ($accesslevel == "user") {
$_SESSION['level'] = "user";
$_SESSION['username'] = $_POST['UserName'];
$_SESSION["userid"] = login($_POST);
include ('userlogin.php');
exit();
}
}
else {
//$_SESSION['loggedIn'] = false;
unset ($_SESSION['userid']);
unset ($_SESSION['username']);
unset ($_SESSION['level']);
echo "Error :$error";
}
}
//ob_end_flush();
?>
<BODY>
<FORM id=form1 name=loginform  method=post>



so after login user is directed to the corresponding page.

The problem is that when some user is logged in to the user page
or admin page, at the same time if i want to login to the user
page from other computers , it lets me login but after that
whatever link i click in userlogin page, takes me back to login
page. And i have to log in to userpage and click on log out and
then it will work.
its quite strange and i dont know why it is acting like this.
Also in userlogin page i am have a link to other page which i am
calling by
PHP Code:

 if ($_GET['mode'] == "basketball"){
include ('basket_closed.php');
}
and link is userlogin.php?mode=basketball 



My Log out script is
PHP Code:

<?php
session_start();
//store to test if they were logged in
$old_user = $_SESSION['userid'];
//$_SESSION['loggedIn'] = false;
unset ($_SESSION['userid']);
unset ($_SESSION['username']);
unset ($_SESSION['level']);
session_destroy();
?>



I need help on this...i couldn't came up with any clue, Any idea..
i really appreciate your help

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to