a question about sessions and custom sessions

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
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

a question about sessions and custom sessions

Post by kendall »

Hello,

I am asking this question mainly because i am begining to recieve alot of vastly different suggestions in response to it

i am using the server generated session or session is using session_start(PHPSESSID) to track a visitor untill he has finished filling out a form. the reason i did this is because it was the most simplist way i find to identify a person temporaraly

the problem i seem to be facing is that i am unable to unregister or destroy the session. using session_unset() and session_destroy() as after filling out the form and then trying to do it again i notice that the phpsessid is the same even when i flush the browser cache.

why is it not freeing/ destroying the session?

now i was attempting to use a session_id and session_name but kept running into a heaer alreay sent error scenario

was this my best approach? as it seems to work very well with me as the session id was being auto generated for me by php / sever and using it was as easy as echo $PHPSESSID

is there any downfall to this method other than the extra long id # which i dont mind?

Kendall
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

If you are using superglobals ($_SESSION), session_unset does not work. The way to destroy a session is like so:

session_start();
$_SESSION=array();
session_destroy();
unset($_COOKIE[session_name()]);
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

a question about sessions and custom sessions

Post by kendall »

Hey,

Well this is exactly my point

im not using $_SESSION

thus

sessiont_start()
session_unset() or session_unset($PHPSESID)
session_destroy();

should work!

then why isnt it?

Kendall
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

a question about sessions and custom sessions

Post by kendall »

I really am trying to figure out how this session thing works

See im using the $PHPSSESID default session variable to track a visitor tru to the end of a process.

Im trying to session_unset();

and session_destroy() it and it is not being destoryed.

session_unset() suppose to free all session variables right? isnt $PHPSESSID a variable?

how do i then destroy the $PHPSESSID ? so that when the person comes back he gets a new $PHPSESSID?

Kendall
Post Reply