sstangle73 Posted August 28, 2007 Share Posted August 28, 2007 they dont set when i come back to my site they arent there they dont show up in ff's list any ideas? if(isset($_POST['remember'])){ setcookie("cookname", $_SESSION['username'], time()+60*60*24*365, "/"); setcookie("cookpass", $_SESSION['password'], time()+60*60*24*365, "/"); setcookie("name", $_SESSION['name'], time()+60*60*24*365, "/"); setcookie("email", $_SESSION['email'], time()+60*60*24*365, "/"); setcookie("bdate", $_SESSION['bdate'], time()+60*60*24*365, "/"); setcookie("sex", $_SESSION['sex'], time()+60*60*24*365, "/"); setcookie("city", $_SESSION['city'], time()+60*60*24*365, "/"); setcookie("state", $_SESSION['state'], time()+60*60*24*365, "/"); setcookie("level", $_SESSION['level'], time()+60*60*24*365, "/"); setcookie("ID", $_SESSION['ID'], time()+60*60*24*365, "/"); setcookie("dname", $_SESSION['dname'], time()+60*60*24*365, "/"); setcookie("quote", $_SESSION['quote'], time()+60*60*24*365, "/"); setcookie("color", $_SESSION['color'], time()+60*60*24*365, "/"); } Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 Try sending all of the parameters, not just those Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 extra note setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted August 28, 2007 Author Share Posted August 28, 2007 moving up to the top didnt work what baffles me the most is the cookies set untill a certain point in that list [i added more features and in turn more cookies] im not sure exactly where they stopped but. Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 Are all of those session variables set? Do you have error reporting turned on? ini_set('display_errors', 1); error_reporting(E_ALL); Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted August 28, 2007 Author Share Posted August 28, 2007 the only errors that show are Notice: Undefined index: level in /homepages/27/d193007783/htdocs/stangle/login.php on line 130 Notice: Undefined index: ID in /homepages/27/d193007783/htdocs/stangle/login.php on line 130 Notice: Undefined index: username in /homepages/27/d193007783/htdocs/stangle/login.php on line 130 Notice: Undefined index: color in /homepages/27/d193007783/htdocs/stangle/login.php on line 130 witch have to do with something else it should effect the cookies heres my entire login page <?php if(isset($_POST['remember'])){ setcookie("cookname", $_SESSION['username'], time()+60*60*24*365, "/"); setcookie("cookpass", $_SESSION['password'], time()+60*60*24*365, "/"); setcookie("name", $_SESSION['name'], time()+60*60*24*365, "/"); setcookie("email", $_SESSION['email'], time()+60*60*24*365, "/"); setcookie("bdate", $_SESSION['bdate'], time()+60*60*24*365, "/"); setcookie("sex", $_SESSION['sex'], time()+60*60*24*365, "/"); setcookie("city", $_SESSION['city'], time()+60*60*24*365, "/"); setcookie("state", $_SESSION['state'], time()+60*60*24*365, "/"); setcookie("level", $_SESSION['level'], time()+60*60*24*365, "/"); setcookie("ID", $_SESSION['ID'], time()+60*60*24*365, "/"); setcookie("dname", $_SESSION['dname'], time()+60*60*24*365, "/"); setcookie("quote", $_SESSION['quote'], time()+60*60*24*365, "/"); setcookie("color", $_SESSION['color'], time()+60*60*24*365, "/"); ini_set('display_errors', 1); error_reporting(E_ALL); } function checkLogin(){ /* Check if user has been remembered */ if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){ $_SESSION['username'] = $_COOKIE['cookname']; $_SESSION['password'] = $_COOKIE['cookpass']; $_SESSION['name'] = $_COOKIE['name']; $_SESSION['email'] = $_COOKIE['email']; $_SESSION['bdate'] = $_COOKIE['bdate']; $_SESSION['sex'] = $_COOKIE['sex']; $_SESSION['city'] = $_COOKIE['city']; $_SESSION['state'] = $_COOKIE['state']; $_SESSION['level'] = $_COOKIE['level']; $_SESSION['ID'] = $_COOKIE['ID']; $_SESSION['dname'] = $_COOKIE['dname']; $_SESSION['quote'] = $_COOKIE['quote']; $_SESSION['color'] = $_COOKIE['color']; } /* Username and password have been set */ if(isset($_SESSION['username']) && isset($_SESSION['password'])){ /* Confirm that username and password are valid */ if(confirmUser($_SESSION['username'], $_SESSION['password']) != 0){ /* Variables are incorrect, user not logged in */ unset($_SESSION['username']); unset($_SESSION['password']); unset($_SESSION['name']); unset($_SESSION['email']); unset($_SESSION['bdate']); unset($_SESSION['sex']); unset($_SESSION['city']); unset($_SESSION['state']); unset($_SESSION['level']); unset($_SESSION['ID']); unset($_SESSION['dname']); unset($_SESSION['quote']); unset($_SESSION['color']); return false; } return true; } /* User not logged in */ else{ return false; } } function displayLogin(){ global $logged_in; if($logged_in){ echo "<h1>Logged In!</h1>"; echo "Welcome <b>$_SESSION[username]</b>, you are logged in. <a href=\"logout.php\">Logout</a>"; } else{ ?> <h1>Login</h1> <form name=v1 action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post"> <table align="center" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30"></td></tr> <tr><td colspan="2" align="left"><input type="checkbox" name="remember"> <font size="2">Remember me next time</font></td></tr> <tr><td colspan="2" align="center"><input type="submit" name="sublogin" value="Login"></td></tr> <tr><td colspan="2" align="center" bgcolor="#000000"><a href="register.php"><font color="#FFFFFF"><b>REGISTER!</b></font></a></td></tr> <tr><td> </td></tr> <tr><td colspan="2" align="center" bgcolor="#000000"><a href="forgot.php"><font color="#FFFFFF"><b>Forgot Password</b></font></a></td></tr> </table> </form> <?php } } function confirmUser($username, $password){ $query="SELECT * FROM users WHERE username='$username'"; $result=mysql_query($query); while($array=mysql_fetch_assoc($result)){ $uname=$array['username']; } if($uname==$username){ global $conn; /* Add slashes if necessary (for query) */ if(!get_magic_quotes_gpc()) { $username = addslashes($username); } /* Verify that user is in database */ $q = "select password from users where username = '$username'"; $result = mysql_query($q,$conn); if(!$result || (mysql_numrows($result) < 1)){ return 1; //Indicates username failure } /* Retrieve password from result, strip slashes */ $dbarray = mysql_fetch_array($result); $dbarray['password'] = stripslashes($dbarray['password']); $password = stripslashes($password); /* Validate that password is correct */ if($password == $dbarray['password']){ return 0; //Success! Username and password confirmed } else{ return 2; //Indicates password failure } } return 3; //case fail } if(isset($_POST['sublogin'])){ include("func.php"); PageTop($_SESSION['level'], $_SESSION['ID'], $_SESSION['username'], $_SESSION['color']); /* Check that all fields were typed in */ if(!$_POST['user'] || !$_POST['pass']){ exit("<script type='text/javascript'> alert('You Didnt enter a required field!') </script><script type='text/javascript'>history.go(-1)</script>"); } /* Spruce up username, check length */ $_POST['user'] = trim($_POST['user']); if(strlen($_POST['user']) > 30){ exit("<script type='text/javascript'> alert('Sorry, the username is longer than 30 characters, please shorten it.') </script><script type='text/javascript'>history.go(-1)</script>"); } /* Checks that username is in database and password is correct */ $md5pass = md5($_POST['pass']); $result = confirmUser($_POST['user'], $md5pass); /* Check error codes */ if($result == 1){ exit("<script type='text/javascript'> alert('That username doesnt exist') </script><script type='text/javascript'>history.go(-1)</script>"); } else if($result == 2){ exit("<script type='text/javascript'> alert('Incorrect password, please try again.') </script><script type='text/javascript'>history.go(-1)</script>"); } else if($result == 3){ exit("<script type='text/javascript'> alert('That username doesnt exist') </script><script type='text/javascript'>history.go(-1)</script>"); } PageBottom(); /* Username and password correct, register session variables */ $_POST['user'] = stripslashes($_POST['user']); $_SESSION['username'] = $_POST['user']; $_SESSION['password'] = $md5pass; $user=$_POST[user]; $query="SELECT * FROM users WHERE `username` = '$user' "; $result=mysql_query($query); while($array=mysql_fetch_assoc($result)){ $_SESSION['name']=$array['name']; $_SESSION['email']=$array['email']; $_SESSION['bdate']=$array['bdate']; $_SESSION['sex']=$array['sex']; $_SESSION['city']=$array['city']; $_SESSION['state']=$array['state']; $_SESSION['level']=$array['level']; $_SESSION['ID']=$array['ID']; $_SESSION['dname']=$array['dname']; $_SESSION['quote']=$array['quote']; $_SESSION['color']=$array['color']; } /* Quick self-redirect to avoid resending data on refresh */ echo "<meta http-equiv=\"Refresh\" content=\"0;url=$HTTP_SERVER_VARS[php_SELF]\">"; return; } /* Sets the value of the logged_in variable, which can be used in your code */ $logged_in = checkLogin(); ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 It's saying that $_SESSION['level'] and the rest of those aren't set, like I said. Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted August 29, 2007 Author Share Posted August 29, 2007 where that? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.