PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
session_start();
?>
<?php
if ($_REQUESTї"loggedin"] == "t") {s
setcookie("CG_login",$_REQUESTї"username"],time()*60*60*24*365);
echo "OK -".$_REQUESTї"username"];
}
if ($_COOKIEї"CG_login"] && $_REQUESTї"loggedin"] != "t") {
header("Location:Login/LoginSuccess.php?Username=".$_COOKIEї"CG_login"]);
}
else {
// OTHER CODE NOT SHOWN HERE
}
When I Send The Required Details Using The Query String - To Set The Cookie, It Says It Has Done It.
Yet When I Reload The Page, It Goes Straight Into The ELSE Bit
your second part of the if expression requires $_REQUEST['loggedin'] to not equal 't' .. if you just reload the page, loggedin will still be 't' (a requirement of your setcookie() bit.
When I Get Home (At A Different Computer Now), I Will Upload A ZIP File.
Anyone With Apache + MYSQL + PHP5 - Unzip This Into A Directory Of Your Choice, And Run The index2.php in your browser.
Inspect The Code A Bit, You Will Soon See My Problem. It Is In index2.php and Login/LoginSuccess.php
You should write out the process in steps - then compare that to your code.
Then you'll spot that when you set the cookie, the second if condition returns false - not true. Why? Because you seem to assume $_REQUEST["loggedin"] changes value by itself. Unfortunately PHP is not psychic - you need to unset this yourself.
Flowcharts are a great help - requires only paper, a pen and some ability to draw lines...