Cookies
-
hello, i have been having a few issues with my cookies in php ..... First things first is this script below won't work at all... what am i doing wrong ?
if (isset($_COOKIE["user"]) && ($_COOKIE["pass"]))
{
$user=$_COOKIE['user'];
$pass=$_COOKIE['pass'];
}else{$user=mysql_real_escape_string($_POST['username']);
$pass=mysql_real_escape_string(hash('sha512', $_POST['password']));
$remember = (isset($_POST['remember']));
}However, if i take out all the bits in bold, it works perfectly .... The next thing is i tried a number of times to get my cookies to go back to the previous directory using things like "../" at the end but this doesn't seem to work ... what do i need to do to this script ..... Note: this file is 1 sub folder away from the root...
if($remember == 1)
{
$expire=time()+60*60*24*30;
setcookie ("user", "test", $expire);
setcookie ("pass", $pass, $expire);
}Thanks for all your help, steve
-
hello, i have been having a few issues with my cookies in php ..... First things first is this script below won't work at all... what am i doing wrong ?
if (isset($_COOKIE["user"]) && ($_COOKIE["pass"]))
{
$user=$_COOKIE['user'];
$pass=$_COOKIE['pass'];
}else{$user=mysql_real_escape_string($_POST['username']);
$pass=mysql_real_escape_string(hash('sha512', $_POST['password']));
$remember = (isset($_POST['remember']));
}However, if i take out all the bits in bold, it works perfectly .... The next thing is i tried a number of times to get my cookies to go back to the previous directory using things like "../" at the end but this doesn't seem to work ... what do i need to do to this script ..... Note: this file is 1 sub folder away from the root...
if($remember == 1)
{
$expire=time()+60*60*24*30;
setcookie ("user", "test", $expire);
setcookie ("pass", $pass, $expire);
}Thanks for all your help, steve
I'll try and answer a small part: I think you are missing a second isset in the very first line. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.