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