By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

php session expiry

P: 17
Dear
I would like to set session expire time to 3hrs,
Which one is best ?
ini_set("session.cookie_lifetime","10800"); or session_set_cookie_params(3600 * 3);
Or can I use both?
Is it compulsary to place every page b4 where ever session_start();
And one more above said syntax is correct or not? because some people using "10800" and some '10800' others just 10800. how to set?

Thanks. Pls help me
Apr 5 '12 #1

✓ answered by johny10151981

both of them will do the same trick

but 10800 is better than 3600*3, php wont have to parse unnecessary equation. And yes you can use whichever you want.

Yes it is compulsory. in simple when you do session_start it creates all the necessary data list for you page purpose.

"10800" , '10800' and 10800

all of them are correct. it may have performance issue, i am not sure about it though.

but in some cases they will show difference

such as
("10800"==10800) will return 1 i.e. true

("10800"===10800) will return false

cause in the second comparison first data is treated as string and the second data is treated as number.

Share this Question
Share on Google+
5 Replies


100+
P: 1,059
both of them will do the same trick

but 10800 is better than 3600*3, php wont have to parse unnecessary equation. And yes you can use whichever you want.

Yes it is compulsory. in simple when you do session_start it creates all the necessary data list for you page purpose.

"10800" , '10800' and 10800

all of them are correct. it may have performance issue, i am not sure about it though.

but in some cases they will show difference

such as
("10800"==10800) will return 1 i.e. true

("10800"===10800) will return false

cause in the second comparison first data is treated as string and the second data is treated as number.
Apr 6 '12 #2

P: 17
Great,
Thanks lot,
Then why there is two functions for same purpose?
anyway thanks once again. Let i work with this, If problem persists, I ll inform y.
Apr 6 '12 #3

P: 17
Dear Friend,
I used session_set_cookie_params(10800); But now I am facing some problem. After 1 hr (on 65th min)even with activity (frequent clicks on page) at the time of submitting my page its expires, What may be problem? How to fix it?. I tried to work 45 min with activity and submit there is no expiry problem.
I am using shared hosting.
Apr 13 '12 #4

100+
P: 1,059
here is a suggestion from php.net site

Set cookie parameters defined in the php.ini file. The effect of this function only lasts for the duration of the script. Thus, you need to call session_set_cookie_params() for every request and before session_start() is called.
Apr 13 '12 #5

P: 17
Yes, I using session_set_cookie_params(10800); before calling session_start .. each page. Wheter I need edit php.ini? And also I am attaching my current php.ini config file.
Thanks
Attached Files
File Type: doc PHP Version 5.doc (411.0 KB, 37450 views)
Apr 13 '12 #6

Post your reply

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