Page 1 of 1
basic help on sessions
Posted: Sat Aug 29, 2009 8:39 pm
by gimpact
Hello,
For the first time I am creating a user/member login script. I am using session to store info about all logged in user. Here is what I would like to know,
lets say, the user is logged in and the following code executed
Code: Select all
session_start();
$_session['email']= $email;
a. how long will this session last? to prevent excessive server usage when the user is away from the computer, I would like to kill the session. Is there a way?
b. whats best to store in session? an email id? I was wondering if I know some one else email, can I try to use his email, in my session when I am logged it?
c. should i go for a complex numeric data and store it in session for remember logged in user?
Thank you for reading this
Re: basic help on sessions
Posted: Sat Aug 29, 2009 8:52 pm
by requinix
gimpact wrote:a. how long will this session last? to prevent excessive server usage when the user is away from the computer, I would like to kill the session. Is there a way?
Not really, and it's not worth it. PHP will clean up old sessions automatically. "old" is a per-server thing: typical values are 5, 15, or 30 minutes.
gimpact wrote:b. whats best to store in session? an email id? I was wondering if I know some one else email, can I try to use his email, in my session when I am logged it?
Store whatever you want, hopefully to cut down on the number of database queries you have to run.
Users can't see or touch session data - only your code.
gimpact wrote:c. should i go for a complex numeric data and store it in session for remember logged in user?
What?
"Remember me" things store some information in cookies, then use that to log in if it's present and there's no session information yet.
Re: basic help on sessions
Posted: Sat Aug 29, 2009 9:13 pm
by gimpact
Thanks for the info
the 3rd question is related to 2nd question. I was wondering how much can I actually store in session without my server being over loaded with session. The person for whom i am trying to make this, says he expects at least 1000 visitors a day. so i got the be careful not to make my servers go for running computing power for many sessions.
Re: basic help on sessions
Posted: Sat Aug 29, 2009 9:20 pm
by gimpact
I have one more question to ask.
This is how I am expecting my pages to work once the user is logged in
login page
http://www.x.com/members/login/index.php
after success full login
http://www.x.com/members/login/account/?tag=home
now here, this page actually includes another page which is located here
http://www.x.com/members/login/account/PAGES/home.html
in "account/index.php" i am making a check for session. if no session user is redirected, if there is session the "home.html" gets loaded. I was wondering is it really necessary to make another session check with in "home.html"? my "PAGES" folder is hidden in the server from public views.
Thank you,
Re: basic help on sessions
Posted: Sat Aug 29, 2009 10:00 pm
by requinix
gimpact wrote:I was wondering how much can I actually store in session without my server being over loaded with session.
Like I said, store whatever you want.
gimpact wrote:I was wondering is it really necessary to make another session check with in "home.html"? my "PAGES" folder is hidden in the server from public views.
Hidden or inaccessible?
If you can't get to home.html any other way then you can make index.php handle all the work.