matthew798 Posted September 10, 2008 Share Posted September 10, 2008 hola. So ive got my whole admin system working (if any of you have been following the compendium of posts i've been making, you'll know what i'm up to.) The only thing that ISNT working, is the logout. Or it is, i just cant start up a session after i log out. This is the logout script <?php session_start(); session_destroy(); ?> Now it works. Only when i try to login again with ANY credentials (of course only ones in the DB) NONE of the variables get defined. It's like the session cant register anything anymore. Did i end it right? It worked fine BEFORE i destroyed it, then after, everything is undefined... Link to comment https://forums.phpfreaks.com/topic/123698-session-destroy-and-restart/ Share on other sites More sharing options...
Asheeown Posted September 11, 2008 Share Posted September 11, 2008 I use: <?php session_start(); unset($_SESSION); ?> quick and easy Link to comment https://forums.phpfreaks.com/topic/123698-session-destroy-and-restart/#findComment-638741 Share on other sites More sharing options...
matthew798 Posted September 11, 2008 Author Share Posted September 11, 2008 exact same amount of characters but anyways lol... Like i said, NOTHING is registering. For some reason, no global variables are registering AT ALL. Not even ones from the DB... WTF IS GOING ON!!?!? This is what processes login and assaign vars to the $_SESSION <?php session_start(); include 'dbconnect.php'; $username = ($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $sql="SELECT * FROM users WHERE username='$username' and password='$password'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("$username"); header("location:admin.html"); } else { echo "Wrong Username or Password. Use the back button. If you think this message is incorrect, contact the webmaster."; } ?> Link to comment https://forums.phpfreaks.com/topic/123698-session-destroy-and-restart/#findComment-638743 Share on other sites More sharing options...
Asheeown Posted September 11, 2008 Share Posted September 11, 2008 Sure your php.ini file is setup correctly? Link to comment https://forums.phpfreaks.com/topic/123698-session-destroy-and-restart/#findComment-639428 Share on other sites More sharing options...
betazoid Posted September 12, 2008 Share Posted September 12, 2008 I had that problem too, what i did to get round it was send the sid to the browser, login.php <?php require 'sessions.inc.php'; session_start(); // same as your code roughly logout.php <?php require 'sessions.inc.php'; session_start(); unset($_SESSION); session_destroy(); echo "you are now logged out"; BUT i also use a line ini_set("session.cookie_domain", ".mysite.com"); That goes before the session start, and mysite replace with your site name of course. Im new to php and thats what worked for me, my globals are set to off - and safe mode is on, and my browser doesnt really like cookies, so i echoed the session id which the browser then happily accepts, once I log out, and then click any link on any page i get in the address bar http://somesite.com/page.php?PHPSID=ad399dodc for example, maybe that would work for you too. Link to comment https://forums.phpfreaks.com/topic/123698-session-destroy-and-restart/#findComment-639436 Share on other sites More sharing options...
DarkWater Posted September 12, 2008 Share Posted September 12, 2008 Probably because you're using session_register, and in the wrong way, might I add. session_register() is deprecated anyway, so just use the $_SESSION[] superglobal. Link to comment https://forums.phpfreaks.com/topic/123698-session-destroy-and-restart/#findComment-639443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.