RE: [PHP] Session Variables
| From: | .ben | Date: | Tue, 16 Apr 2002 22:03:48 +0000 |
| Subject: | RE: [PHP] Session Variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-93261@lists.php.net to get a copy of this message | ||
I have a function that i call at the beginning of each page (well, those
that require user auth).
checkLogin()
this checks for a positive integer value in a session variable called
intUserID
$_SESSION['intUserID'];
is that isn't a positive integer, i redirect to the login page.
the login is split into two script, prompt and process. prompt is a form
which POSTs data to the process script which in turn verifys the
username/password and if valid, assigns $_SESSION['intUserID'] the value of
the users user ID.
all looks fine to me.
.b
p.s. is it just me or is the reply-to on this list a little odd?
> -----Original Message-----
> From: Phil Powell [mailto:soazine@erols.com]
> Sent: 16 April 2002 22:50
> To: php-general@lists.php.net
> Subject: [PHP] Session Variables
>
>
> I understand the concept of session variables, so I want to know the best
> methodology of approaching this:
>
> 1) HTML redirect to PHP page
> 2) PHP page looks for session
> a) If found, show some stuff
> b) If not found, prompt user for username and password
> 3) If no session, prompt user for username and password, once entered & is
> ok, set session and redirect
>
> Following is a code snippet I borrowed that I think would work, correct me
> if I'm wrong:
>
> // Setting a name for our session.
> session_name("hasLoggedIn");
> // Starting Session.
> session_start();
> // Register vars into session
> session_register("username");
> // Setting values for session vars.
> $HTTP_SESSION_VARS["username"]=$HTTP_POST_VARS["username"];
> // Referring a session info to another PHP.
> echo "<A HREF=\"somefile.php?" . session_name() . "=" .
> session_id() .
> "%s\">text</A>";
>
> Thanx!!
> Phil
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>