473,396 Members | 2,024 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,396 software developers and data experts.

Session Disappears After 30 Minutes

I'm running PHP Version 4.3.10. I'm trying to make it so that when a
person logs in using a user name and password that their session is
valid and continues for a few months so they don't have to log in each
time they come to the site.

In a .htaccess file I set session.cookie_lifetime to 20736000 seconds
and I set session.gc_maxlifetime to 20736000

It works for about 30 minutes. A user can login and then close their
browser and then open the browser and go back to the site and they are
automatically logged in, just like I want. But after 30 minutes it
stops working. The cookie is still there but it seems like the session
has been wiped but I don't know why.

Also, according to session.save_path the session data is being stored
in /tmp but when I look in /tmp on the sever I can't find the session
file(s). Anybody know why that is?

The session part of php.ini looks like this:

session.auto_start Off Off
session.bug_compat_42 On On
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_lifetime 20736000 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 100 100
session.gc_maxlifetime 20736000 1440
session.gc_probability 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /tmp /tmp
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid On On

Jul 17 '05 #1
1 4354
On 25 Mar 2005 23:46:58 -0800, "mudge" <mu****@gmail.com> wrote:
I'm running PHP Version 4.3.10. I'm trying to make it so that when a
person logs in using a user name and password that their session is
valid and continues for a few months so they don't have to log in each
time they come to the site.

In a .htaccess file I set session.cookie_lifetime to 20736000 seconds
and I set session.gc_maxlifetime to 20736000
I would caution against having such long-lived sessions; if you want to retain
logons, set a long-lived cookie instead with some form of key that can
re-restablish the logon.
It works for about 30 minutes. A user can login and then close their
browser and then open the browser and go back to the site and they are
automatically logged in, just like I want. But after 30 minutes it
stops working. The cookie is still there but it seems like the session
has been wiped but I don't know why.

Also, according to session.save_path the session data is being stored
in /tmp but when I look in /tmp on the sever I can't find the session
file(s). Anybody know why that is?

The session part of php.ini looks like this:

session.auto_start Off Off
session.bug_compat_42 On On
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_lifetime 20736000 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 100 100
session.gc_maxlifetime 20736000 1440
The session garbage collector piggy-backs itself on PHP requests, with a
probability determined by gc_divisor and gc_probability - default 1% of
requests.

If you have session.gc_maxlifetime set locally, then that only influences
garbage collection runs that were piggy-backed onto requests in this
subdirectory. So it only destroys session files older than 240 days.

But note that the "Master value" on the right is still at 1440, the default of
30 minutes. Garbage collection runs from elsewhere on the site not covered by
your .htaccess will therefore destroy session files older than 30 minutes - it
won't know or care that the session file was created from a subdirectory with
an overridden gc_maxlifetime.

I think if you want different gc_maxlifetime values you also absolutely need
to override save_path as well, else it'll all average out to using the smallest
gc_maxlifetime across all areas.
session.gc_probability 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /tmp /tmp
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid On On


--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

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

Similar topics

2
by: WJ | last post by:
I am setting the Session State TimeOut to 54 minutes (20 is default) in the Web.Config. I use SQL Server to persist the session states & ID. As long as I am remaining in the web sites, I see all...
4
by: JIsenstadt | last post by:
I would appreciate it if anybody can help with a issue I am having in an ASP.NET application that is timing out before a process has been completed. The scenario ASP.NET application under IIS 5...
11
by: Vishal | last post by:
Hello, can anybody tell me how I can extend the session expiry time? Is it done via code or via IIS? Sorry I am new and dont know about this.
17
by: jensen bredal | last post by:
Hello, i'm struggling with a somehow badly understood session scenario. I provide acces to my pages based on form authentication using Session cookies. Som of my pages are supposed to be...
3
by: bennett | last post by:
In the web.config file for my application, in the <sessionState> section I have set timeout="120" (in minutes), but session state variables in my application seem to be expiring in about 5 minutes....
4
by: UJ | last post by:
I have a page where the user can upload a video file. As you can guess, this may take a while. Is there a way I can change the session timeout for just this one page? I would also want to change...
25
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
I tried: <sessionState timeout="1"> </sessionState> bounced IIS, and after 1 minute still had a session. ??? -- thanks - dave
14
by: GaryDean | last post by:
The web.config in my asp.net application, running on Server2003, has this entry: <sessionState mode="InProc" timeout="40". In IIS the asp.net State Management timeout setting is 40 for my website....
9
by: antonyliu2002 | last post by:
By default, IIS is configured to timeout a session in 20 minutes, which can be changed through the IIS config window. I use InProc sessionState mode. I can also set the session timeout in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.