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

Recommended Answers

All 2 Replies

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.