RE: Log-in form and sessions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> http://www.php.net/docs.php


Boy, *that's* helpful. Good to see we have such a helpful community here.
Gives me the idea to make postcards that say "RTFM" and hand them out to
anyone who asks me a question at the next chamber of commerce meeting.

I've never used ASP, but my sense is that sessions are pretty similar. You
start a session by calling session_start() and must use it on every page
that requires sessions. Session variables can be accessed via the $_SESSION
array. So if you have a variable called $userID that you want available on
very page in the session, you just set it's value during login:
$_SESSION['userID']=$_POST['userID'] (assuming the info is submitted via
post with an input named userID).

A common practice is to check the value of a session variable and if it's
not set, redirect to a login page, thus:

If((_SESSION['logged_in']==1) {
	//valid login
} else {
	//not logged in, redirect to login form
}

...assuming you set $_SESSION['logged_in']=1 during the login process

Sessions time out (I think the default is 1440 seconds), so if someone has
loaded a page for a while, they will have to re-login.

More info about sessions is at http://www.php.net/manual/en/ref.session.php

There are some security risks with sessions, so make sure you read up on
that part of the manual.

-Derek


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/saFolB/TM
---------------------------------------------------------------------~->

Look here for Free PHP Classes of objects:
http://phpclasses.UpperDesign.com/
To unsubscribe from this group, send an email to:
php-objects-unsubscribe@egroups.com

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux