Page 2 of 2

Posted: Wed May 31, 2006 5:16 pm
by RobertGonzalez
When you say connection details, what are you talking about?

Posted: Wed May 31, 2006 5:27 pm
by Christopher
BigAbe wrote:1) How do I handle timeouts and/or specifying how long I want the user to stay "logged in"?
You can set the session timeout in the php.ini file. You can also do something programatic -- for example every time they acccess a page you check to see if the time in a timestamp saved in a session variable has been passed. If it has not then save a timestamp an hour in the future to that var. If you have passed the save timestamp then clear the session vars and redirect to the login page.
BigAbe wrote:2) Do you recommend keeping the connection data in a session variable? I have one main index page with tons of include() statements, so I can easily just keep the connection details there, but if there's an easier/better way of doing it, I'd love to hear your thoughts.
No. Keep as little as possible and only temporary data necessary to maintain session context for the user.

Posted: Wed May 31, 2006 5:43 pm
by BigAbe
Everah wrote:When you say connection details, what are you talking about?
Database connextion details

Thanks for the tips you two. You've both been a great deal of help!

-- Abe --

Posted: Wed May 31, 2006 5:58 pm
by RobertGonzalez
Database connection details should be stored in an include file a folder below your server root. For example, if your server path is /var/www/public_html/ the you should put your connection details in /var/www/. This is just my opinion. I am sure there are many different, viable approaches to this question.

As for session data... the whole concept of a session is the time a user spends visiting your site. Their 'session' if you will, is the time they are at a particular position. Storing information outside the scope of the session is not a recommended use of session handling. Again, this is my opinion.

Bonus question

Posted: Mon Jun 05, 2006 5:05 pm
by BigAbe
If on page 1 I declare

Code: Select all

$_SESSION['var'] = 1;
then go to page 2 and say

Code: Select all

$var = 2;
if I go to page 3, what should

Code: Select all

echo $_SESSION['var'];
display?

Just wondering...

Posted: Mon Jun 05, 2006 5:58 pm
by RobertGonzalez
1.