PHP Sessions - Not Destroying

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
Sjwdavies
Forum Commoner
Posts: 25
Joined: Mon Nov 17, 2008 10:18 am

PHP Sessions - Not Destroying

Post by Sjwdavies »

Hi guys.

I've got a fresh Apache/PHP installation, and it was my impression that when using start_session(), the PHP session expired when the browser was closed?

However, it appears the sessions still stay active. I'm writing an online insurance quote application and want the session to be destroyed if the user gets part way through a quote but then closes the window.

Am I missing something really obvious?

Any help is greatly appreciated.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP Sessions - Not Destroying

Post by VladSun »

php.ini
session.cookie_lifetime integer
session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0. See also session_get_cookie_params() and session_set_cookie_params().

Note: The expiration timestamp is set relative to the server time, which is not necessarily the same as the time in the client's browser.
There are 10 types of people in this world, those who understand binary and those who don't
Sjwdavies
Forum Commoner
Posts: 25
Joined: Mon Nov 17, 2008 10:18 am

Re: PHP Sessions - Not Destroying

Post by Sjwdavies »

Thanks for the reply.

I've checked that already, it's set to zero.

Here's what my ini file has
; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0
Any ideas?
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: PHP Sessions - Not Destroying

Post by novice4eva »

viewtopic.php?f=1&t=90176
I am not sure about the session expiring thing when the browser is closed!! I read a thread saying the same but i just couldn't believe it coz i had never experienced it, so i tried to change the session "THING" in the php.ini and could finally get the session destroyed on browser close and even page refreshes but that was coz i set the session.use_cookies to 0 and then forgot to send the session id as the get parameter :crazy:
User avatar
airy
Forum Newbie
Posts: 20
Joined: Fri Jul 11, 2008 2:53 am

Re: PHP Sessions - Not Destroying

Post by airy »

function session_destroy() doesn't work well in lower version of php
please make sure your php version, U may found more information about that in php manual
Post Reply