March 12, 201214 yr So I was wondering for password check if it's possible to reset a session? For when one get redirected to another website the session will either, A: Be Destroyed. B: Be Reseted. I have treid the session_destroy function but nothing that can bring it out. It namely fully destroys it with no reset. if($mysqlnumrows!=1) { $_SESSION['check']=$_SESSION['check']+1; if(!isset($_SESSION['check'])) {echo "";} if ($_SESSION['check']==5); { die("Treid to many times"); } Anyway for explanation; I want once the $_SESSION reach 5 it will redirect the person to another page. Once redirected and return to the inlog page the $_SESSION must be 0 again. How do I accomplish this?
March 12, 201214 yr if ($_SESSION['check']==5); { $_SESSION['check'] = 0; die("Treid to many times"); }
March 12, 201214 yr if(!isset($_SESSION['check'])){ //It's dangerous to go alone! Take this. $_SESSION['check'] == 0; } if($mysqlnumrows != 1){ $_SESSION['check']++; } if ($_SESSION['check'] >= 5){ die("Your mission is a failure"); } Edited March 12, 201214 yr by Spitfire
March 12, 201214 yr if(!isset($_SESSION['check'])){ //It's dangerous to go alone! Take this. $_SESSION['check'] == 0; } if($mysqlnumrows != 1){ $_SESSION['check']++; } if ($_SESSION['check'] >= 5){ die("Your mission is a failure"); } mmm should this $_SESSION['check'] == 0; not be this $_SESSION['check'] = 0;
March 13, 201214 yr Author It´s fun to see like all of those is not realy working as intended. This however correctly works: if($mysqlnumrows != 1) { $_SESSION['check'] == 1; $_SESSION['check']++; echo $_SESSION['check']; } if ($_SESSION['check'] ==5) { header:("Location:http://localhost/admin/failed.php"); unset($_SESSION['check']); } } It unset the session once it reached 5 and starts up again. However you might notice the header location I added. For some reason the header location just does not seem to work stand alone if I post it any where else. Any though on it to get it to work? Edited March 13, 201214 yr by kensha
March 13, 201214 yr Author Alright so I found it out thanks by google and I will post the working solution for you guys. the full default header location won't work when there is a tag in the current document. For example: <html> <?php header:("Location:http://localhost/admin/failed.php"); ?> </html> However once you specify a variable for the url itself then the code would work. For example: <?php $URL="../index.php"; header ("Location: $URL"); ?>
March 16, 201214 yr Alright so I found it out thanks by google and I will post the working solution for you guys. the full default header location won't work when there is a tag in the current document. For example: <html> <?php header:("Location:http://localhost/admin/failed.php"); ?> </html> However once you specify a variable for the url itself then the code would work. For example: <?php $URL="../index.php"; header ("Location: $URL"); ?> For future reference you cannot change the page location if there has already been any output to the browser. That includes white space.
Create an account or sign in to comment