php - Session variables not carrying over -
i'm trying write log in script set session variable , redirect user page. session variables displays fine on page it's set, on next page not display @ all. have stripped down home page echo session variable.
login.php:
session_start(); if(isset($_post['process_login'])){ include('php/db.php'); $query = mysql_query("select users.username, users.password users") or die (mysql_error()); while ($result = mysql_fetch_array($query)){ if (strtoupper($_post['username']) != $result['username'] || md5($_post['password']) != $result['password']){ echo "<center><font color=red>incorrect username or password</font><center>"; } else{ $_session['username'] = $_post['username']; #echo $_session['username']; #printr ($_session); echo "<script> window.location = \"home.php\"; </script>"; } //echo $result['username']; } }
home.php
session_start(); echo $_session['username'];
the way you've got set should work fine.. code have?
Comments
Post a Comment