Jump to content

php sessions not acting as intended


bouwob

Recommended Posts

ok I have this at the top of every page

 

if (!isset($_SESSION['user']))
{
session_start();
$_SESSION['user'] = "4";
$_SESSION['browse'] = "4";
echo "ho";
}

if (isset($_SESSION['user']))
{
echo "hi";
$userid = $_SESSION['user'];	
}
else
$userid = "";
if (isset($_SESSION['browse']))
$browseid = $_SESSION['browse'];	
else
$browseid = "";

echo $_SESSION['browse']."----".$_SESSION['user'];

 

when I get to any page I get a printout of "hohi4----4 "

 

and then I have a login page with this code

if ($_POST["user"] != "UserName" && $_POST["password"] != "Password")
	{
	$query = "select username, userid from users where username = '".$_POST["user"]."' and password = '".$_POST["password"]."'";
	$result = querydatabase ($query);
	while($row = mysql_fetch_assoc($result))
		{
		$username = $row['username'];
		$userid = $row['userid'];
		}
	echo ($username == $_POST["user"]).$userid;
	if ($username == $_POST["user"])
		{
			$_SESSION = array(); 
			session_destroy();
			session_start();
			$_SESSION['browse'] = "5";
			$_SESSION['user'] = $userid;
			$whatToDo = "display uname"; 
		}
}

 

when I go to that page and login I get a print out of this "11hi5----1"

 

ok everything up untill this point is working as intended. the problem is that when I then click a home link I get "hohi4----4 " when it should say "hi5----1". Are sessions directory sensitive? The home page does not have any other session code other than the 1st section of code I posted. The sessions are dieing when going from the login page to the home page.

 

any ideas?

 

if you go to

 

http://www.nolanryancardmuseum.com/login/index.php

 

you can play around with it. just hit submit to login

 

tia

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.