dazza12345
Programmer
Hi, I hope someone can help me out with this problem as its starting to seriously bug me.
Right, the following code is the first thing in my php script:
<?
$logusername = $_POST['logusername'];
$logpassword = $_POST['logpassword'];
if ($logusername != ""){
ob_start();
setcookie("bewiseusername", $logusername, time()+3600);
setcookie("bewisepassword", $logpassword, time()+3600);
ob_end_flush();
echo"SAVE COOKIE";
}
$bewiseusername = $logusername;
$bewisepassword = $logpassword;
if ($bewiseusername == ""){
echo "GET VALUSE FROM COOKIE";
$bewiseusername = $HTTP_COOKIE_VARS["BewiseBetsusername"];
$bewisepassword = $HTTP_COOKIE_VARS["BewiseBetspassword"];
}
What will happen is; a user will enter their username + password (using a form) then will click 'login' button which will call the same script again (using $_SERVER['PHP_SELF']
.
Im trying to get the username and password saved into two cookies. This is not as easy as I first thought. Once the user clicks the submit button, the username and password are saved into the two varables ($logusername and $logpassword) and 'cookie saved' is outputted onto the screen.
However, the cookie does not seem to want to save. In another php script, I have put the following code:
<?
if(isset($_COOKIE['bewiseusername'])) {
echo "cookie exists";
}
else {
echo "cookie dont exists";
}
?>
Every time, it will output "cookie dont exist". I really have no idea what is going wrong with saving the cookie. Anyone with any additional knowledge of setting cookies, PLEASE, PLEASE HELP.
Kind Regards
Daryl
Right, the following code is the first thing in my php script:
<?
$logusername = $_POST['logusername'];
$logpassword = $_POST['logpassword'];
if ($logusername != ""){
ob_start();
setcookie("bewiseusername", $logusername, time()+3600);
setcookie("bewisepassword", $logpassword, time()+3600);
ob_end_flush();
echo"SAVE COOKIE";
}
$bewiseusername = $logusername;
$bewisepassword = $logpassword;
if ($bewiseusername == ""){
echo "GET VALUSE FROM COOKIE";
$bewiseusername = $HTTP_COOKIE_VARS["BewiseBetsusername"];
$bewisepassword = $HTTP_COOKIE_VARS["BewiseBetspassword"];
}
What will happen is; a user will enter their username + password (using a form) then will click 'login' button which will call the same script again (using $_SERVER['PHP_SELF']
Im trying to get the username and password saved into two cookies. This is not as easy as I first thought. Once the user clicks the submit button, the username and password are saved into the two varables ($logusername and $logpassword) and 'cookie saved' is outputted onto the screen.
However, the cookie does not seem to want to save. In another php script, I have put the following code:
<?
if(isset($_COOKIE['bewiseusername'])) {
echo "cookie exists";
}
else {
echo "cookie dont exists";
}
?>
Every time, it will output "cookie dont exist". I really have no idea what is going wrong with saving the cookie. Anyone with any additional knowledge of setting cookies, PLEASE, PLEASE HELP.
Kind Regards
Daryl