SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    setcookie problem

    Hi,

    I'm getting this really weird problem with my script.

    It doesn't seems like the setcookie() function is working in any pages aside from the index page off the root directory of my domain.

    Does anyone know why and how could I get round that problem?

    Here's my code:

    <?
    setcookie("name", $name, time()+7200);
    ?>

    and then on another page, I have

    <?
    echo $name;
    echo $_COOKIE["name"];
    echo $HTTP_COOKIE_VARS["name"];
    ?>

    and none of these work.

    Anyway, anyhelp is appreciated.
    Cheers

  2. #2
    SitePoint Addict Clete2's Avatar
    Join Date
    Mar 2002
    Location
    Columbia, South Carolina
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if it would make a difference, but you already have a $name and you named the cookie $name... Also I could never get cookies to work on PHP4.2.X...
    My Blog
    My Photography Website
    Linux user #339185

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when you use the setcookie() function, try putting the cookie domain and the cookie path in there also. check out http://php.net/setcookie and see exactly what order they go in. by specifying those two additional things, it might make the cookies work.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •