Re: Sessions

From: Date: Fri, 24 Nov 2000 10:53:02 +0000
Subject: Re: Sessions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-27072@lists.php.net to get a copy of this message
Try this. <? function mtime() { $mtime = microtime(); $mtime = ereg_replace('\.', '', $mtime); $mtime = explode(' ', $mtime); $mtime = $mtime[1] . $mtime[0]; return($mtime); } session_start(); if (isset($logout)) session_unset(); if (!isset($SessionID)) { $SessionID = mtime(); session_register("SessionID"); } ?> If you send a variable ($logout) to the script it will log the user out. SessionID is garaunteed to be unique as long as your servers time is semi stable :) Sessions are great, you start using them, you'll love them ! Here's a little something to play with, try classes and sessions together :) more information on these functions are at http://www.php.net/manual/function.microtime.php http://www.php.net/manual/function.session-start.php http://www.php.net/manual/function.session-register.php Chris Lee Mediawaveonline.com In article <001c01c05681$961e1e20$554d59d5@chello.se>, broder_b@chello.se wrote: > ------=_NextPart_000_0019_01C05689.F7B95340 > Content-Type: text/plain; > charset="iso-8859-1" > Content-Transfer-Encoding: quoted-printable > > Yo! I'm currently writing some code that is going to verify a user by an > = unique session id. The session id is saved in a database and is valid > = for some time, before a user is forced to log on to the site again. I > = need to randomly generate the session id and I have to be absolutely = > sure of that it is unique, and it is here I have some problme. I don't = > know just how to do this. I guess the easiest way to accomplish this is > = by using the session support in php, but how does it work? > > ------=_NextPart_000_0019_01C05689.F7B95340-- >

« previous php.general (#27072) next »