Re: Member authentication with PHP and MySQL

From: Date: Mon, 13 Aug 2001 15:37:08 +0000
Subject: Re: Member authentication with PHP and MySQL
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-11297@lists.php.net to get a copy of this message
If you note the part of the script where the cookie is set //make unique session id and store it in Database $timer = md5(time()); $sid = $UserID . "+" . $timer; SetCookie("Cookiename",$sid,time()+2592000); file://Set Cookie for 30 days $query = "update members set sid=\"$timer\" where UserID=\"$UserID\""; I set the cookie with the user id and a Session ID I create... then when it checks the cookie it just does $sidarray = explode("+", "$Cookiename"); $query = "select * from members where UserID = \"$sidarray[0]\" and sid = \"$sidarray[1]\""; So using this script you could put whatever else you wanted in the cookie. You would just change $sid = $UserID . "+" . $timer; to $sid = $UserID . "+" . $timer . "+" . $email; for example. Then when you do $sidarray = explode("+", "$Cookiename"); You would have $sidarray[0] = $UserID $sidarray[1] = $timer $sidarray[2] = $email You could continue adding additional variables (or plain strings for that matter) in this manner. The only thing to keep in mind is that cookies have a 4K file size limitation and anything beyond 4K will be lost. Check under additional notes on this page for details on cookie limitations http://www.netscape.com/newsref/std/cookie_spec.html I hope all that is clear. Let me know if you have any more questions Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com ----- Original Message ----- From: Cato Larsen <ravenno1@world-online.no> To: <php-db@lists.php.net> Sent: Monday, August 13, 2001 9:06 AM Subject: Re: [PHP-DB] Member authentication with PHP and MySQL > Thanks a mill Sheridan! > This was accually what I was looking for, but gave up since the other > tutorials and script examples where too complicated for me to grasp. > > One question to the code on the site: > > Is it possible to insert info to be grabbed on other sites? > Like > email > password > name > > So you can grab like name, instead of having to querity the DB all the time > you need the name of the person and so on? > And if yes, how do you get it from the cookie and insert it into the page > like $name ? > > Best regards > > Cato Larsen > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#11297) next »