SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: cookies

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Location
    Florence, Italy
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've searched the forum on cookies but couldn't find an answer to my question.

    This is the first time I'm setting cookies but it doesn't work entirely.

    This is what I put before the HTML tag. The reason why I have both "email" and $email is because I started out passing the variables with links and I figure this way I don't have to change the code <? if ($email)........?> on all the pages

    <?php
    SetCookie("email",$email,time()+86400);
    ?>

    In any event, it works partly because within the site because if I log in twice (to test) it will continue using the first name I logged in with. But it doesn't work when I leave the site and come back. I then have to log in again. Anybody have any idea what I'm doing wrong?

    Willow

  2. #2
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes.. here is the problem.. you don't have the domain set for it!

    proper way:
    PHP Code:
    // Domain without [url]http://[/url] or www
    $domain "yourdomain.com";
    // Hours for it to last
    $time 24;
    // Set cookie
    setcookie ("email"$emailtime()+(3600*$time), "/"".$domain"0); 
    hope this helps...
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Location
    Florence, Italy
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup! that was it... THANKS!
    I actually don't really understand why none of the tutorials I looked at even used this parameter. Cookies would often be used for returning visitors or not?
    And the PHP manual didn't explain what the domain name was for either.


    Whatever, I'm set now. Thanks again.

    Willow


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
  •