Jump to content

My computer has a mind of its own...


Rifts

Recommended Posts

I have used sessions before I don't know whats going on.

 

My sessions wont die.

 

this is what im doing:

 

<?php
session_start();

$_SESSION['user'] = $_POST['email'];
$_SESSION['pass'] = $_POST['pass'];

?>

 

ok new page

 

<?php
session_start();

echo $_SESSION['user'];
echo "<br>";
echo $_SESSION['pass']
?>

 

OK great is show the same info but now if I close my browser and go back to the second page where it echos it still shows the user//pass

I have tried restarting and it still saves the dam session!

 

Should it kill the session if i close my browser?

 

wtf?

 

Link to comment
https://forums.phpfreaks.com/topic/218244-my-computer-has-a-mind-of-its-own/
Share on other sites

It depends on the session.cookie_lifetime setting (assuming that you are passing the session id using a cookie) or if you are passing the session id on the end of the URL and you are using a URL that contains the session id when you revisit the second page after opening your browser.

Assuming you haven't overridden any settings, sessions are stored in a temporary file on your server's file system.

 

The session file is named after the user's session ID, which is stored either (a) in the user's PHPSESSID cookie, or (b) in the URL.

 

When the user visits the site, his cookie/URL are analyzed and the proper file is loaded into memory as $_SESSION.

 

Check the URL you're using.  If there's a 32-character hexadecimal code there that you don't recognize, it's your session ID, and anyone who uses that URL will get the same session as you.  This is why URL-based sessions are frowned upon and rarely used.

 

If there's no session ID in the URL, then you have a cookie called PHPSESSID on your browser.  It SHOULD be deleted once all your browser windows are closed, but it won't necessarily.  You'll have to delete the cookie by hand to clear your session.

 

-Dan

well i fixed it and i dont understand why this worked...

 

instead of setting the session like this:

 

  $_SESSION['user'] = $_POST['email'];

 

I did

 

$email = $_POST['email'];

$_SESSION['user'] = $email

 

and now everything works fine... weird huh?

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.