HighDots Forums  

PHP Session end problems

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss PHP Session end problems in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
alwaysabitlost
 
Posts: n/a

Default PHP Session end problems - 08-04-2004 , 03:49 PM






Hi guys

I've built a shopping cart, and at the end of the transaction, the completed
page is meant to destroy the cookie holiding the users session id and return
them to the front page with an empty basket and a nice new session.

Problem is while the cookie disappears fine, I can't seem to end the session
unless I close all the browser windows

I'm using the following code

<?php
setcookie ("mysite", "", time() - 3600);

session_start();
session_destroy();
session_unset();

if( isset($HTTP_COOKIE_VARS["mysite"]) )
unset( $HTTP_COOKIE_VARS["mysite"] );
?>

Anyone got any thoughts as to why it's not binning the session? Thanks.


Reply With Quote
  #2  
Old   
N Rohler
 
Posts: n/a

Default Re: PHP Session end problems - 08-04-2004 , 04:00 PM






Just a tip...when removing cookies, use time()-86400 or more, so that if the
user is in a different time zone than the server the cookie will still be
removed.

Here's a script from php.net that should remove the session cookies. You also
need to use session_destroy after session_unset.

session_start();

$CookieInfo = session_get_cookie_params();
if ( (empty($CookieInfo['domain'])) && (empty($CookieInfo['secure'])) ) {
setcookie(session_name(), '', time()-3600, $CookieInfo['path']);
} elseif (empty($CookieInfo['secure'])) {
setcookie(session_name(), '', time()-3600, $CookieInfo['path'],
$CookieInfo['domain']);
} else {
setcookie(session_name(), '', time()-3600, $CookieInfo['path'],
$CookieInfo['domain'], $CookieInfo['secure']);
}
unset($_COOKIE[session_name()]);
session_unset();
session_destroy();


Reply With Quote
  #3  
Old   
alwaysabitlost
 
Posts: n/a

Default Re: PHP Session end problems - 08-04-2004 , 04:49 PM



Hmm, still no dice...

I can't figure it out.

Reply With Quote
  #4  
Old   
Adenocard
 
Posts: n/a

Default Re: PHP Session end problems - 08-04-2004 , 05:20 PM



I remember running into this a while back.. something to do with
session_register() which has been deprecated. Take a look in the php manual
..chm edition notes.. I think it is there, and I will try to see if I can find
how I rectified this before.




Reply With Quote
  #5  
Old   
alwaysabitlost
 
Posts: n/a

Default Re: PHP Session end problems - 08-04-2004 , 05:59 PM



Hi fellas

Cheers for the input, I finally got round it by deleting the cookie and
unsetting/destroying the session before going to the secure payment page which
did the business.

It's all gravy ;?)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.