Re: session question
| From: | Richard Lynch | Date: | Sat, 24 Feb 2001 01:26:18 +0000 |
| Subject: | Re: session question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-41415@lists.php.net to get a copy of this message | ||
> index.php where they log in from
> <?
> session_start(); file://first line of file
Okay.
> ?>
> <form method="POST" action="main.php">
> <input type="hidden" value="lrlogin" name="form_action">
> Username <input type="text" name="username"
> class="color"><br
/>
<br/> ? You been typing too much XML?... :-)
Shouldn't hurt.
> Password <input class="color" type="password"
name="password"><br
> />
> <input type="reset"> <input
> type="submit" value="Login">
>
> code from main.php
> <?
> session_register();
Register what? You're supposed to register a variable name...
> require ("db.php");
> if $form_action == "lrlogin"
> {
> get_user($username,$password);
> }
> ?>
>
> code from db.php
> <?
> session_start();
Doing this after you registered a variable is bogus -- The
session_register() automatically calls this if you haven't yet.
> SQL to select user info from db
> $access = $row[access_level]; file://etc getting vars from db
> session_register("username");
> session_register("password");
> session_register("access");
> session_register("active");
> header("Location:!–ʸÅ,›äö�F
> ÜÉ
http://www.blah.com/index2.php?=".SID);
Doing session_start() (and, by extension, session_register()) in the same
file as a header("Location:") won't work on some browsers. You'll either
get the cookie but no redirection or vice versa, depending on which browser
you are using.
And there should be a space after 'Location:'
And you probably need SID= for the SID to get passed on.
header("Location: http://www.blah.com/index2.php?SID=".SID);
> exit;
> ?>
>
> index2.php code
> <?
> session_start();
>
> print "Welcome $username";
> ?>
>
> it only prints Welcome ...no username :(
--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm