Re: Sessions help needed!

From: Date: Sat, 05 Jul 2003 23:05:51 +0000
Subject: Re: Sessions help needed!
References: 1  Groups: php.install 
Request: Send a blank email to php-install+get-11227@lists.php.net to get a copy of this message
John Have you checked the setup of your session management? Check the setting as reflected in the output from a phpinfo() command. for example, make sure your session storage path is valid etc. (normally /tmp if you haven't changed it) Also check how php is set to access variables. (Look at the setting for register_variables, and check the manual for an explanation of how this *may* affect you) Make sure your test browser is set to accept cookies too ... if the setting in php.ini for session.use_cookies is ON (value 1) then session data is transported via cookies, blocking these in the browser means the data doesn't propogate. TD On Sat, 2003-07-05 at 20:39, John Fuller wrote: > Hello all, > I am new to php in general and am trying to set up a user authentification system with > mysql. The registration page works well and sends all of the data to the appropriate table in > mysql. However, when I try to get the registered user to log in and start a session, the system > will not remember the session information past the page. For instance, this page will not work (the > one that initially is supposed to register the session from the login form): > > <? > session_start(); > $username="chris"; > $database="login"; > > $login = $_POST['login']; > $password = $_POST['password']; > if((!$login) || (!$password)){ > echo "Please enter ALL of the information! <br />"; > include 'login.php'; > exit(); > } > mysql_connect(localhost,$username); > @mysql_select_db($database) or die( "Unable to select database"); > $sql=mysql_query("SELECT * FROM login WHERE login='$login' AND > password='$password'"); > $login_check = mysql_num_rows($sql); > if($login_check > 0){ > // This is where I register the session > session_register('login'); > $_SESSION['login'] = $login; > mysql_close(); > include 'success.php'; > } else { > echo "You could not be logged in! Either the username and password do not match or you > have not validated your membership!<br /> > Please try again!<br />"; > include 'login.php'; > } > ?> > > It proceeds to login the user for that page (I know this happens because I have played around > with it looking at the error checks), but it will not display any variable that resembles > "$_SESSION['login']". > The next page sequentially (success.php) looks like this: > > <? > session_start(); > echo 'Successful login for "$_SESSION['login']"'; > ?> > > Any and all variations of this page come up blank and white whenever the variable > $_SESSION['login'] is called to display. It shows no memory of me registering a session. > Any variation of quotes verse apostrophes changes nothing, so I figure that either I am blatantly > screwing up the session code (possible for I have never written any sessions before) or my system is > not supporting sessions. I have a php4 something, windows, apache 1.3.27 for my home network > server, and mysql. Any help on this problem would be greatly appreciated. > Thanks a lot for your time, John > > > > > --------------------------------- > Do you Yahoo!? > SBC Yahoo! DSL - Now only $29.95 per month! -- Tony Dietrich <td@transoft.demon.co.uk> Transoft Computer Consultants

« previous php.install (#11227) next »