[SOLVED] Sessions - Gotta Be An Easy One

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Subliminal
Forum Commoner
Posts: 40
Joined: Thu Oct 23, 2003 8:12 pm

[SOLVED] Sessions - Gotta Be An Easy One

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the browser likely, still has it's session cookie.. you may want to call [php_man]session_regenerate_id[/php_man]()
Subliminal
Forum Commoner
Posts: 40
Joined: Thu Oct 23, 2003 8:12 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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)
Subliminal
Forum Commoner
Posts: 40
Joined: Thu Oct 23, 2003 8:12 pm

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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?
Subliminal
Forum Commoner
Posts: 40
Joined: Thu Oct 23, 2003 8:12 pm

Post 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
Post Reply