473,385 Members | 1,772 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,385 software developers and data experts.

Extend Session Timeout Depending on users

Hi All

I know I can set the php.ini timeout to increase to what ever I like
I also know I can do it from a php script.

My question is if I can change it from the script will it extend the seesion for all users or only the user who intiated the call from the script?

If not how can I set intranet users to have a time out of 1hr and internet users 15mins

any help would be greatly appreciated
Apr 29 '08 #1
5 2522
TheServant
1,168 Expert 1GB
Hi All

I know I can set the php.ini timeout to increase to what ever I like
I also know I can do it from a php script.

My question is if I can change it from the script will it extend the seesion for all users or only the user who intiated the call from the script?

If not how can I set intranet users to have a time out of 1hr and internet users 15mins

any help would be greatly appreciated
Interesting. Does your script work? I am pretty sure that unless your script changes the php.ini file, it will not change it for the other users. Post the code for doing it from the script. I am guessing you could do a small if statement to test whether it's an intra or inter user and submit the appropriate timeout.

Is it something like:
[PHP]//Change the session timeout value to 1 hr
ini_set(?session.gc_maxlifetime?, 60*60);
[/PHP]
Apr 29 '08 #2
dlite922
1,584 Expert 1GB
You would be able to differentiate between internet and intranet users by their IP address.

Usually the intranet has a specific subnet (most commonly 192.168.x.x)

get the users IP and match it to that subnet and you can distinguish between intranet and internet.

You can be sure, no one will have 192.168.x.x IP on the internet, that's reserved, but if its something else, fire your system admin. (joke)

-DM
Apr 29 '08 #3
coolsti
310 100+
I am not sure how you can do this by manipulating php.ini. Frankly I don't think that would work, because changes to php.ini do not take effect until the (Apache) server is restarted, at least on a Linux system (if I am not mistaken here).

I described in my post to this thread another way you can do something similar:

http://bytes.com/forum/thread795054.html

Basically you leave the php.ini driven session life time to be relatively long, and you use the method I describe to time a user out if the difference between the time of their next page request and the time of their last page request is longer than the amount of time allowed for them. This way, you can make the maximum time allowed user dependent. When a user is timed out, you call session destroy functions to remove their session and session files.

I am doing this with two maximum times, one if the user is within the intranet and one if they are coming from outside.
May 2 '08 #4
The Servant that is pretty much my script

I like the check ip address suggestion. On every page, as apart of a security stragety I check to to see if the session is active. I could (if I understand correctly) check how long that session has been going for and kick them out if they have been around longer than 15 mins and from an external ip.

Interesting. Does your script work? I am pretty sure that unless your script changes the php.ini file, it will not change it for the other users. Post the code for doing it from the script. I am guessing you could do a small if statement to test whether it's an intra or inter user and submit the appropriate timeout.

Is it something like:
[PHP]//Change the session timeout value to 1 hr
ini_set(?session.gc_maxlifetime?, 60*60);
[/PHP]
May 6 '08 #5
coolsti
310 100+
The Servant that is pretty much my script

I like the check ip address suggestion. On every page, as apart of a security stragety I check to to see if the session is active. I could (if I understand correctly) check how long that session has been going for and kick them out if they have been around longer than 15 mins and from an external ip.
This is what I do. When a user logs on, I create an identity string composed of an identifier for the application that the user logged on to (I have a few different databases each requiring a separate log in), and the IP address, and store this in a session variable. Then at the start of every page request (I do this with a function called from an auto_prepend file script so it is called with every PHP request) I compre this stored session variable with the user's IP address and the application specific identifier. If no match, I log the user out (destroy the session) and present the log in page again.

I also give the user a much shorter allowable interval between page requests when coming from an external IP address.
May 7 '08 #6

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

Similar topics

4
by: Yuriy | last post by:
Hi, everybody! I need every 20 min extent my Session timeout. Any suggetions appreciated! Thanks
2
by: Yuriy | last post by:
Hello ! I have a problem with session variables and i need to do something with my session I need every 20 min extend my Session timeout. Any suggetions appreciated! Thanks
5
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the...
5
by: Just D. | last post by:
Do we have any access to the Session object from a different Session? The idea is to save Session of a current user and then if he logs in again then return the Session back. It's not a problem to...
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...
1
by: Seetha J | last post by:
I work on a website where users can apply for different types of loans. Depending on the type of loan we store various sets of data in Session state which is maintained in SQL Server. If the user...
2
by: Kevin Frey | last post by:
Hello, I've been reading that ASP.NET serialises (ie. processes one at a time) HTTP requests if two simultaneous requests need to access the same session state. It also makes note that ASP.NET...
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
7
by: anithaapr05 | last post by:
Hi, I am creating a session when user successfully login to the site and user gets a form to input some data into database. Assume that user entered data into some fileds and let the browser...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.