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

How to extend the lifetime of $_SESSION?

mikek12004
200 100+
I use a $_SESSION variable to store the username and wish to last longer that it does (only for this php script) is there a way?
Jul 22 '09 #1
9 3241
Dormilich
8,658 Expert Mod 8TB
sure, overwrite the session.gc_maxlifetime value with ini_set(). see Session Runtime Configuration
Jul 22 '09 #2
Dheeraj Joshi
1,123 Expert 1GB
Dormilich is right

change this

session.gc_maxlifetime in php.ini.........
Jul 23 '09 #3
Canabeez
126 100+
Following question...

If you're overriding the session.gc_maxlifetime in one PHP script, and then run another one under the same session, will the the lifetime "get shorter" after you run the second script?
Jul 23 '09 #4
dlite922
1,584 Expert 1GB
Yes, if you want this value to remain for any page with session, you have to have this declared.

If you want the entire server (php global setting) just change it in your php.ini like dheerajjoshim suggested vs what Dorm suggested.

Cheers,



Dan
Jul 23 '09 #5
mikek12004
200 100+
in the php script the in_set("session.gc_maxlifetime",2000) will go below the session_start() right?
Jul 27 '09 #6
Dormilich
8,658 Expert Mod 8TB
I usually set php.ini values as early as possible.
Jul 27 '09 #7
mikek12004
200 100+
yeah but can you do it before session_star()? (Normaly isn't this going at the very top?)
Jul 29 '09 #8
Dormilich
8,658 Expert Mod 8TB
@mikek12004
not necessarily, it just has to be called before any use of $_SESSION and any output.

personal note: using a class for sessions comes in handy there because the class will invoke session_start() when necessary (tho you still need to watch out for previous output)
Jul 29 '09 #9
mikek12004
200 100+
Got it, I will try first the init_set and then the session start and if I do not have any errors I will leave it this way, thanks
Jul 30 '09 #10

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

Similar topics

0
by: Phil Powell | last post by:
What is the most standardized method of utilizing the CURL functions in PHP (version 4.3.2) to be able to retrieve the contents of a remote URL that happens to be dependent upon $_SESSION for its...
5
by: h | last post by:
I am at my wits end; I can not see A SINGLE THING I'm doing wrong. I've read every fricking session related doc. I've searched every fricking group. NO ONE seems to have had the problem I'm having...
1
by: poppy | last post by:
I am currently caching some objects on the client in a windows application but was wondering if it was possible to extend the life of the cache so when I close my application down the contents of...
21
by: axlq | last post by:
Someone please tell me if I've discovered a PHP bug. I'm sitting in front of several computers on my home network, behind a NAT firewall/router. I am testing my web site on these different...
12
by: Michael Windsor | last post by:
I've been trying to integrate some PHP pages of my own with some existing code. The details of this are for the support forums for that code (where I have been asking questions), but I wonder if...
2
by: somecrazyguy | last post by:
Take the following code, one would think that there was absolutely no link between $test and $_SESSION. But if you reload the page, guess what... "After=FAILED". Why? Because for some reason,...
4
by: Pseudonyme | last post by:
Dear Sirs and Madams, Receive as information that storing a MYSQL result under $_SESSION was accelerating web page displays processes ? Absolutly needed but impossible to get this working ! I...
2
by: sharonDonnelly | last post by:
Hi Really dumb problem that's got me beat. Can someone help. The prolem: I'm trying to count the number of times an item has been clicked. There are many items. I want to create a session...
3
by: JRough | last post by:
I want to save two variables in a $_SESSION for use in another page: $_SESSION = $mark; $_SESSION = $num; then on the other page I did this to get the value: $mark =$_SESSION; $num =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...

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.