473,804 Members | 3,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with session...

Hi

I am wondering what goes wrong...
I have

session_cache_e xpire(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 1561
jodleren schreef:
Hi
Hi Jodleren,
I am wondering what goes wrong...
I have

session_cache_e xpire(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_ha ndler (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_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
jodleren schreef:
Hi

Hi Jodleren,
I am wondering what goes wrong...
I have
session_cache_e xpire(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_pa th 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_maxl ifetime, 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_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
>jodleren schreef:
>>Hi
Hi Jodleren,
>>I am wondering what goes wrong...
I have
session_cache_e xpire(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_pa th 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_maxl ifetime, 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_maxl ifetime = 1440

This is also written in the usercontributio n 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
4412
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, but it does not happen with all versions of IE6. I've tested myself only with Mozilla and IE5, but the problem does not occur for me. I've got a username stored in $user, which is obtained from the $_POST variable, but after session_start() is...
8
1763
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 provides the possibility for users to log in. The loginscript and the databases are hosted at server 1. The site at server 2 contains a link to the loginpage at server 1. That works well... so far.
3
2857
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 access to the ASP Session data to run correctly. In order to achieve this I create my own HTTP request for a certain ASP page with the name of Session variable that I want is stored in the query string of the request. The requested ASP page...
7
1874
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 as 2300 ms to complete. This is fairly rare, but the test code below will definitely show it. Somehow, I must not have my design right. The idea of this code is that I do two different types of processing ( 1-starting and 2-ending) based on...
3
3539
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 our file system set up below. Now, in an aspx page, we set as the "src" of our images something like "../images/animage.jpg". If the current actual url in the browser is something like http://server/webapp/(someSessionID)/forms/form1.aspx
4
2181
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 write the information about user name, filename upload, filesize, date and time of uploading into the log file. (The name of the log file is constructed by Current Year and Current Month in my program). Is there any problems with writing into the...
9
2443
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 anything in particular to 'queue' their requests or should asp.net do this? Any help would be very useful, jsale
0
1274
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 this web development process so forgive my ignorance. The third party has a shopping cart which must be saved in the session. When navigating from page to page we experience some odd behavior on the hosted server that we do not see on our...
14
2409
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 standard ASPX page with minor modifications to it. All of my pages inherit from a "BasePage.cs" class, that handles common things like getting the user's information out of the session, determines if a page should or should not be password...
4
2313
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 someone tell me where i am going wrong please. #!/usr/bin/perl use Net::Msmgr; use Net::Msmgr::Session;
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10569
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10315
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9140
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.