RE: [PHP] Sessions and login
| From: | Ford, Mike [LSS] | Date: | Wed, 11 Jun 2003 16:13:27 +0000 |
| Subject: | RE: [PHP] Sessions and login | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-151102@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Wim Paulussen [mailto:wim.paulussen@profile.be]
> Sent: 11 June 2003 14:28
>
> page 1 : login.php
>
> input user name -> Post veriable
> input password-> post variable
>
> page 2 : verify.php
> session_start()
>
> // supposing name is entered
> if (!$_POST['password'] == "")
Strange syntax -- I'd prefer:
if ($_POST['password'] != "")
> {
> // verification against database
> if (successfully authenticated)
> {
> $_SESSION['user'] = $_POST['user'];
> header("location: authPage.php");
To cover all bases, you need to include the SID constant here, so it still
works for people who don't accept cookies. Oh, and the header name must be
Location (note capital L) to conform with the standard, and the URL should
be an absolute one -- some fussy browsers won't do the redirection properly
if this isn't 100% correct:
header("Location: http://your.site.name/path/to/authPage.php?".SID);
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211