SN1P3R_85 Posted December 25, 2008 Share Posted December 25, 2008 I made a program that generates random passwords for a user if they want to have their password reset. At the end, i make an array, and save its value into a session var. For some reason, the session var wont' set. <?php session_start(); include( 'SQL_PASS.inc' ); $valid = $_SESSION['passresetvalid']; $id = $_SESSION['id']; if ($valid == false) { //gonna put ip logger here die('There was an error, password was not reset'); exit(); } srand ((double) microtime( )*1000000000000); $password = "" . rand(0, 9) . ""; $alphabet = 'abcdefghijklmnopqrstuvwxyz'; $digits = 10; $digits = $digits - 2; while ($digits >= 0) { $alphanum = rand(1, 50); $alphanum = $alphanum % 2; if ($alphanum == 1) { $password .= "" . rand(0, 9) . ""; } else { $casenum = rand(1, 50); $casenum = $casenum % 2; $letter = $alphabet[rand(0, 26)]; if ($casenum == 1) { $letter = strtoupper($letter); } $password .= "" . $letter . ""; } /*for($x=5; $x<=rand(50, 100); $x++) { echo ""; for($y=5; $y<=rand(50, 100); $y++) { echo ""; for($z=5; $z<=rand(50, 100); $z++) //extra delay { echo ""; } } }*/ $digits--; } if (!$con) { die('Could not connect to database: ' . mysql_error()); //if cannot connect, kills program and displays msg } elseif (!$db_select) { die('Could not select database: ' . mysql_error()); //if cannot select db, kills program and displays msg } $query = "UPDATE `users` SET Password='$password' WHERE Id='$id'"; $result = mysql_query($query); if (!$query) { die('major error has occured'); exit(); } $query = "SELECT * FROM `users` WHERE Id='$id'"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $recipient = $row['Email']; $subject = 'lost password'; $mailbody = 'Hello ' . $row['Username'] . ',<br />Your password has been successfully reset. Your new password is: <b>' . $password . '</b> . I reccommend that you change it, and you can do that at the control panel on your account.'; $header = "From: www.*********.com\n"; $header .= "To: " . $recipient . "\n"; $header .= "MIME-Version: 1.0\n"; $header .= "Content-type: text/html; charset=iso-8859-1\n"; $email_msg = mail($recipient, $subject, $mailbody, $header); } if (!$email_msg) { die('Error sending email'); } $message = "Your password has been successfully changed. An email has been sent with your new password. We recommend that you change your password as soon as you get your new one. You will now be redirected back to the homepage in "; $delay = 5; $location = "http://www.caidenhome.com"; $redirdata = array($message, $delay, $location); $_SESSION['redirpack'] = $redirdata; // THIS IS THE SESSION THAT WON'T SET, RIGHT HERE !!!! unset($_SESSION['passresetvalid']); unset($_SESSION['id']); header("location: http://www.********.com/redirect.php"); exit(); ?> Link to comment https://forums.phpfreaks.com/topic/138366-solved-session-var-will-not-set/ Share on other sites More sharing options...
SN1P3R_85 Posted December 25, 2008 Author Share Posted December 25, 2008 I didnt' realize how large the code was, session that won't set is at bottom of code. Link to comment https://forums.phpfreaks.com/topic/138366-solved-session-var-will-not-set/#findComment-723493 Share on other sites More sharing options...
BloodyMind Posted December 25, 2008 Share Posted December 25, 2008 you can serialize it use serialize() and when calling unserialize() easier to handle arrays in different environments, I didn't understand what u wanted to do anyways but it's all fine lol Link to comment https://forums.phpfreaks.com/topic/138366-solved-session-var-will-not-set/#findComment-723499 Share on other sites More sharing options...
SN1P3R_85 Posted December 25, 2008 Author Share Posted December 25, 2008 I fixed it, i cut and pasted the code back, and it somehow worked, lol. I'm guessing it was some kind of server error. Link to comment https://forums.phpfreaks.com/topic/138366-solved-session-var-will-not-set/#findComment-723501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.