Jump to content

Sessions


ShaolinF

Recommended Posts

Hi Guys,

 

I created some session variables and was planning on using them on another page. But they don't seem to be getting passed over. See code below:

 

page1.php - Session created and works fine

If(!isset($_SESSION['LOGGEDIN'])) // If user does not have a session
	{		
		//Add session
		$_SESSION['NAME'] = $_POST['name'];

	}

 

page2.php - output session, value is nothing.

session_start();

echo "name:" . $_SESSION['NAME'] . "<BR>";
die;

Link to comment
https://forums.phpfreaks.com/topic/87645-sessions/
Share on other sites

I dont know why you are checking their session to set a session, why dont you just set them both when they log in.

 

Besides that, make sure session_start() is the first thing in both your pages and check your session save path to make sure it's correct.

Link to comment
https://forums.phpfreaks.com/topic/87645-sessions/#findComment-448290
Share on other sites

I found the problem, now I need to find another way around it.

 

<FORM>

<INPUT type="button" class="altButtonFormat" value="Start Over" onClick="location.href='index.htm?id=<?php include("rand.htm"); session_unset(); session_destroy(); ?>'">

</FORM>

 

The point of that was so when they click the link it would redirect the to the home page and destroy the session.  :-\ Do you guys have any other suggestions on how I could achieve this ?

Link to comment
https://forums.phpfreaks.com/topic/87645-sessions/#findComment-448298
Share on other sites

If you want to maintain their username, just reset the session variable you want to reset instead of all of them and destroying it.

Well there are about dozen other variables involved, I only included one for the sake of simplicity. It's a purchase system. The user has the choice of starting over which will reset all the variables.
Link to comment
https://forums.phpfreaks.com/topic/87645-sessions/#findComment-448304
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.