RE: [PHP] Poblem with sesions
| From: | Peter Lauri | Date: | Tue, 20 Feb 2007 05:32:40 +0000 |
| Subject: | RE: [PHP] Poblem with sesions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-249059@lists.php.net to get a copy of this message | ||
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:arizal@bgnet.bgsu.edu]
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