Jump to content


Photo

no cookies recall


  • Please log in to reply
2 replies to this topic

#1 feyrerm

feyrerm
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 18 August 2006 - 07:59 PM

I cant figure out why this code is not working. I created a test script wich esentually is the same as in my full site and it still isnt recalling the cookies. it sets them and the info inside is correct, but on a revisit to the page it does not recall the cookie.
here is the script.

<?php

$domain = "";
$duration = time()+(60*60*24*30);
$loginUsername = "user";
$password = "password";


if (!isset($_COOKIE['visited'])) {
    // if a cookie does not exist
    // set it
    setcookie("lr_user", $loginUsername, $duration, $domain);
    setcookie("lr_pass", $password, $duration, $domain) or die("Could not set cookie");
    echo "This is your first visit here today.";
}
else {
    // if a cookie already exists
    echo "Nice to see you again, old friend!";
}

?>

any help would be great.


#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 18 August 2006 - 08:16 PM

neither of your cookies are called 'visited' - why set two cookies - decalre an aray of values in one cookie - much neater
follow me on twitter @PHPsycho

#3 feyrerm

feyrerm
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 18 August 2006 - 08:21 PM

Man I can't even believe I couldent figure that one out. Sometimes you just need somone elses eyes!!

The two cookies thing is just the way it was written in the borrowed script, I wanted to get it working as written before I modify it becase as you can tell I have enough sintax problems figuing out others code, without trying to write my own. Thanks again!!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users