473,439 Members | 1,926 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,439 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 2524
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...
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
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
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...
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,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.