RE: [PHP] SESSION variable to pass login ID
| From: | Willie G | Date: | Sun, 12 Jan 2003 19:52:59 +0000 |
| Subject: | RE: [PHP] SESSION variable to pass login ID | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-131348@lists.php.net to get a copy of this message | ||
Tom,
I do have a session_start() in both files, but it does not seem to help.
- Larry
-----Original Message-----
From: Tom Rogers [mailto:trogers@kwikin.com]
Sent: Sunday, January 12, 2003 11:36 AM
To: Willie G
Cc: php-general@lists.php.net
Subject: Re: [PHP] SESSION variable to pass login ID
Hi,
Monday, January 13, 2003, 1:04:49 AM, you wrote:
WG> Hi,
WG> I have been trying to solve the problem of using session variables, but
I
WG> have not had any luck. What I want to do is simple, I want to set my
userid
WG> and password in a login screen and use it later (in another php form) to
log
WG> into the database.
WG> In my login PHP file I have the following:
WG> if(isset($_POST['userid']) && isset($_POST['pword'])){
WG> $_SESSION['user'] = $_POST['userid'];
WG> $_SESSION['password'] = $_POST['pword'];
WG> }
WG> In my connect to database PHP file I have:
WG> if(isset($_SESSION['user'])){
WG> $user=$_SESSION['user'];
WG> echo "Print $user";
WG> }else{
WG> echo "Print Missing User";
WG> }
WG> The message I always get is "Print Missing User", so I must assume the
WG> global variable is not working. Can anyone help me out here?
WG> Thanks,
WG> Larry
Make sure you have session_start() at the begining of the second file.
--
regards,
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php