Page 1 of 1

[SOLVED] Sessions - Gotta Be An Easy One

Posted: Mon Aug 30, 2004 7:20 pm
by Subliminal
Hey Guys,

Me again.

I am now trying to use sessions across multiple pages and then kill? unset? or destroy? the session... I just get rid of the SID at the last page so when we go back to the first page it will create a new SID. Just like closing the browser and reopening.

For some reason it just ain't happening.

Below isn't my code but the methods I am using for the sessions.

Code: Select all

<?php

session_start(); // using this to start my session on each page - at the top before any browser output

$some_var = $_SESSION['some_var']; // setting session variables like this

session_unset(); // get rid of all the sessions values
$_SESSION = array(); 	
session_destroy(); // destroy session - won't that get rid of the SID???

?>
Thanks a million guys.

Posted: Mon Aug 30, 2004 7:24 pm
by feyd
the browser likely, still has it's session cookie.. you may want to call [php_man]session_regenerate_id[/php_man]()

Posted: Mon Aug 30, 2004 7:59 pm
by Subliminal
Oddly enough I tried that and forgot to mention that it didn't work either.

Any other possibilities... could it have anything to do with global variables being off?

thanks again

Posted: Mon Aug 30, 2004 8:04 pm
by feyd
so lets get this part straight:

you "delete" the session on page a, and it still shows in page b? or is this all in page a? (page a being page request one, page b being page request two)

Posted: Mon Aug 30, 2004 8:09 pm
by Subliminal
Page A starts a session and adds a session value
Page B starts a session (same one i guess) and asks for another value from the user.. then on the same page after the user presses bumit the same page is evaluated again (yes it does start a session and then does a query depending on the value the user selected. After that it does the destorying part.

Then if i go back to A the SID is the same. refreshing page of course

BTW why is this required

$_SESSION = array();


thanks

PS excuse the double post!

Posted: Mon Aug 30, 2004 8:25 pm
by feyd
$_SESSION = array() will make sure the session data is wiped out.

I've never had problems with a lingering session id when I've deleted the cookie.. maybe you didn't actually delete the cookie?

Posted: Mon Aug 30, 2004 8:35 pm
by Subliminal
Hey,

Thanks... yet another easy fix. I put the pages on another webserver. There must be something weird happening is PHP on the first server.

Thanks for your patience, help, and confirming that I was not crazy... yet anyway...

Later