473,396 Members | 1,722 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.

PHP Session Time Limit

I am currently developing a site and noticed that after about 2 minutes, I am being logged out of the members area.

I have been trying to find a function that will allow me to specify the time limit but I have been unable to find an example of the where to place the function (i.e at the top of the page with the rest of the session info).

Can someone please provide me with a function, how to use it and where about it goes in the script.

Regards
James
Aug 1 '07 #1
9 15705
Motoma
3,237 Expert 2GB
For clarity: did you build the site entirely, or is this something you have come across in someone else's code you are maintaining?
Aug 1 '07 #2
realin
254 100+
well if u talking about sessions, then u surely can do it with ini_set if you donn wanna mess around with php.ini

this worked for me

Expand|Select|Wrap|Line Numbers
  1.   ini_set('session.gc_maxlifetime',14400);
  2.   ini_set('session.gc_probability',1);
  3.   ini_set('session.gc_divisor',1); 
ofcourse u can replace 14400 by ur custom seconds
Aug 1 '07 #3
For clarity: did you build the site entirely, or is this something you have come across in someone else's code you are maintaining?
I built the site entirely!
Aug 1 '07 #4
well if u talking about sessions, then u surely can do it with ini_set if you donn wanna mess around with php.ini

this worked for me

Expand|Select|Wrap|Line Numbers
  1.   ini_set('session.gc_maxlifetime',14400);
  2.   ini_set('session.gc_probability',1);
  3.   ini_set('session.gc_divisor',1); 
ofcourse u can replace 14400 by ur custom seconds

Thanks, Where do i place this in the page? Does it matter?
Aug 1 '07 #5
nathj
938 Expert 512MB
Thanks, Where do i place this in the page? Does it matter?
I'm not sure if it matters, but I always put this sort of thing at the top - before anything else - the place you would put session_start().

That has always worked for me.

Cheers
nathj
Aug 2 '07 #6
kovik
1,044 Expert 1GB
Thanks, Where do i place this in the page? Does it matter?
The session garbage collector works off of this information, so do it before session_start(), or the expired sessions will be removed before you get a chance to alter the settings.
Aug 2 '07 #7
I'm not sure if it matters, but I always put this sort of thing at the top - before anything else - the place you would put session_start().

That has always worked for me.

Cheers
nathj

Thanks for that Nathj
Aug 2 '07 #8
The session garbage collector works off of this information, so do it before session_start(), or the expired sessions will be removed before you get a chance to alter the settings.

Cheers mate

James
Aug 2 '07 #9
well if u talking about sessions, then u surely can do it with ini_set if you donn wanna mess around with php.ini

this worked for me

Expand|Select|Wrap|Line Numbers
  1.   ini_set('session.gc_maxlifetime',14400);
  2.   ini_set('session.gc_probability',1);
  3.   ini_set('session.gc_divisor',1); 
ofcourse u can replace 14400 by ur custom seconds
Thanks for the code. You saved me a nightmare!!!! Works beautifully.
Jul 6 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
6
by: bonehead | last post by:
I'm still a novice when it comes to session security issues. The problems I'm trying to solve may be fairly common, but I haven't seen examples of solutions in any of the books I've looked at. I...
4
by: Wilson | last post by:
I am currently running Oracle 8i with Apache setup in a 4-CPUs Windows 2000 Server. Users on their workstations connect to Oracle through Internet Explorer which accesses Apache's DAD object and...
6
by: Gonenc Ercan | last post by:
Hi, I ve ended up debugging a ASP.NET project (with about 380 files on the project .NET Framework 1.0 on IIS 5.0) which has a memory leak... The memory rises too fast. With about 25-30 active...
6
by: Weave | last post by:
I would like to redirect to a logout page after a session has timed out. I have placed a response.redirect "loggedoff.asp" in the Session_OnEnd subroutine in the global.asa, but it does not move...
0
by: nbdy9(nospam) | last post by:
I have a ASP.Net website (mobile). From time to time the browser popup the following message. Anyway to catch the error and redirect to my start page? saying, login.aspx? Thanks. ...
4
by: MrBiggles | last post by:
Here's the sitch: I read in a csv file with 60000 lines (20 fields per record), and store the data to a local array. The file is read in and stored just fine and pretty quick. Now, if I try to...
1
by: juergen | last post by:
Hi, there are many postings on this subject, I have read them put don't have an answer. I get these warnings: Cannot send session cookie - headers already sent in, but my php-scripts are okay. ...
13
by: Goofy | last post by:
Does anyone know how I can kill a session by session ID ? -- Goofy
3
by: =?Utf-8?B?U2FjaGluIFNha2k=?= | last post by:
Hi, Our application have asp and .aspx pages, we need to redirect user from asp page to .aspx page and vice-versa and want to share session state b/w asp and asp.net. This could be achieved by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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...
0
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,...

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.