1,105,546 Community Members

best practise for managing session??

Member Avatar
learning_php
Newbie Poster
5 posts since Dec 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi
While learning how to create and manage a session, I got through session time out technique, I got throw 2 ways :

1. Setting up garpage collection directive in php.ini file and
2. Create a session variable named, say, EXPIRE that holds the value

$_SESSION['EXPIRES']=time()+360;

at the beginning of a session and then keep checking if it's the correct time to expire or not yet.

My question is : which is the best practice in practical life? to depend on the server configuration file? or create your custom time out session??


Thank you in advance

Member Avatar
chrishea
Posting Virtuoso
1,526 posts since Sep 2008
Reputation Points: 182 [?]
Q&As Helped to Solve: 256 [?]
Skill Endorsements: 6 [?]
 
0
 

What is your objective in "managing" the session. PHP will take care of this for you automatically. If you need to make the session timeout shorter or longer there are values in php.ini that you can change. I'd say that best practice is to leave it alone unless you have a specific need.

Member Avatar
learning_php
Newbie Poster
5 posts since Dec 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

What is your objective in "managing" the session?

Hi Chrishea,

Thank you for your reply, I was thinking about multi-language website, creating a session variable with the selected language , or the default if none selected, and if no response received during certain time, destroy the session (that's the default language will be viewed not the previwsly selected one).

Please correct my thinking as I'm a beginner and it's my 1st time to do this.

Thank you

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: