Re: SESSION variable to pass login ID

From: Date: Sun, 12 Jan 2003 16:36:11 +0000
Subject: Re: SESSION variable to pass login ID
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-131341@lists.php.net to get a copy of this message
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

« previous php.general (#131341) next »