473,326 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Problems with session...

Hi

I am wondering what goes wrong...
I have

session_cache_expire(30);
session_start();

How can I check whether the _last_ session (from e.g. yesterday) has
ended?
My problem is, that once logged in, it remembers it forever. All
$_SESSION variables will stay and will confuse my software next time
they open a browser again, as it can see that the $_SESSION data are
still present...
Is there a way to get to know, that the session has ended, or the
browser has been closed?

WBR
Sonnich

Oct 22 '08 #1
3 1544
jodleren schreef:
Hi
Hi Jodleren,
I am wondering what goes wrong...
I have

session_cache_expire(30);
session_start();

How can I check whether the _last_ session (from e.g. yesterday) has
ended?
You cannot, unless you use own sessionhandlers.

http://nl3.php.net/manual/en/functio...ve-handler.php
My problem is, that once logged in, it remembers it forever. All
$_SESSION variables will stay and will confuse my software next time
they open a browser again, as it can see that the $_SESSION data are
still present...
Possibly this happens because nobody else use that site.
Sessions are destroyed besaed on a random generator.

On the top of my head it is dafault configured with a chance of 1/100
the system will check for stale sessions.
This means that EVERY request to PHP has a 1/100 chance of firing the
session-garbage collection.

Check you php.ini for excact sessting (or use phpinfo()).

Is there a way to get to know, that the session has ended, or the
browser has been closed?
Browser close? No.
Session ended? Yes, with proper session_save_handler (via a db eg).

Regards,
Erwin Moller
>
WBR
Sonnich

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
Oct 22 '08 #2
On 22 Oct, 16:33, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
jodleren schreef:
Hi

Hi Jodleren,
I am wondering what goes wrong...
I have
session_cache_expire(30);
session_start();
How can I check whether the _last_ session (from e.g. yesterday) has
ended?

You cannot, unless you use own sessionhandlers.
You can't have a session without using a session handler. You can roll
your own, but there's no need. The default session handler just uses
files - see session.save_path for the directory. To find out when the
session was last used check the mtime (or the atime - but that may
have been updated by backup software etc).
>
Possibly this happens because nobody else use that site.
Sessions are destroyed besaed on a random generator.
Note that the session will be considered closed if its not accessed
after session.gc_maxlifetime, even thought the file may still persist.
Its only cleaned up when the housekeeping job kicks in (based on a
dice throw when any session_start using the same handler is called for
any session).

C.
Oct 23 '08 #3
C. (http://symcbean.blogspot.com/) schreef:
On 22 Oct, 16:33, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
>jodleren schreef:
>>Hi
Hi Jodleren,
>>I am wondering what goes wrong...
I have
session_cache_expire(30);
session_start();
How can I check whether the _last_ session (from e.g. yesterday) has
ended?
You cannot, unless you use own sessionhandlers.

You can't have a session without using a session handler. You can roll
your own, but there's no need. The default session handler just uses
files - see session.save_path for the directory. To find out when the
session was last used check the mtime (or the atime - but that may
have been updated by backup software etc).
>Possibly this happens because nobody else use that site.
Sessions are destroyed besaed on a random generator.

Note that the session will be considered closed if its not accessed
after session.gc_maxlifetime, even thought the file may still persist.
Its only cleaned up when the housekeeping job kicks in (based on a
dice throw when any session_start using the same handler is called for
any session).
That is not true C,
I find my sessions just alive an kicking after a day (or 2 in this case).
My session.gc_maxlifetime = 1440

This is also written in the usercontribution by 'Vextor':
here: http://nl3.php.net/manual/en/ref.session.php (4 april 2008)
It seems that the garbage engine can't delete the expired session
related to the itself. If there is only one session, it won't expire
even if it has expired the gc_maxlifetime set.

It will be necessary another client connecting, starting a different
session, and the garbage collector of this new session will be able to
clean the other expired sessions.
Regards,
Erwin Moller
>
C.

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
Oct 24 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Daniel Bengs | last post by:
Hi there... I've got a problem where a normal string variable loses its value after session_start() is called. The funny thing is, that this only happens for some people, and they are using IE6,...
8
by: Marc Hoeve | last post by:
Hi everybody I'm setting up 2 websites for a friend of mine, en I'm have problems with one of the sites. The situation: I have 2 different domains (both in the .NL domain). Both domains...
3
by: headware | last post by:
I have an issue that I've been encountering in an ASP application I'm working on. Most of the application is written in ASP, but there is one page written in ASP.NET. The ASP.NET page needs to have...
7
by: Mr. Mountain | last post by:
In the following code I simulate work being done on different threads by sleeping a couple methods for about 40 ms. However, some of these methods that should finish in about 40 -80 ms take as long...
3
by: Scott | last post by:
Hello, we are having problems displaying non-aspx files (images, style sheets) since we have upgraded to the 1.1 framework when using a cookieless session (sessionID in the url). Check out...
4
by: HNguyen | last post by:
Hi, I have a Web application in ASP.NET. My Application allows the users upload files into the server after checking their user names and passwords. For each transaction, the Web program will...
9
by: jsale | last post by:
Hello, I am having a problem with multiple users using my asp.net application - namely that if each user clicks save at the same time, some, or all, of the users crash out. Do I need to do...
0
by: Peter R. Vermilye | last post by:
I am involved on a web application that is using a third party set of APIs for remote database access (middleware). I've been brought in because of my background in programming, thus I'm new to...
14
by: multiformity | last post by:
So I have been working on an opensource project for a while, and decided to really try to make it look better after focusing on the functionality most of this time. Up to now, I have simply used a...
4
by: jonathan184 | last post by:
Problems sending IM from perl MSN messenger Hi I am trying to send a msn message from perl msn messenger but I am trying to send am essage and nothing works. This is the cod eI am using could...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.