SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Oct 2005
    Location
    Home
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cookie setting help...

    I am having problems with cookies again. I have this code:
    PHP Code:
    setcookie('Nathan','blah',time()+3600); 
    But it does not set in my browser, nor in my friends browser. We are using Safari, the default browser that comes with MacOSX. If you would like to test out the code, please go to the page below:
    http://samrusch.com/cookieset.php

    If you go to this page, please give me the following information:
    Your Browser:
    Your Operating System:

    Thank you.

  2. #2
    SitePoint Enthusiast jonoxer's Avatar
    Join Date
    Sep 2004
    Location
    Melbourne, Australia
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Was set correctly in my browser (where "correctly" means the value was "blah"!). Browser and OS shouldn't be relevant unless the cookies are being blocked by a specific browser setting, but you may need to check whether you have any time issues: you're setting the expiry period to "now +3600" but that may not be enough if there's a timezone mismatch between your computer and the server. One of the annoying things about cookies is that the expiry time is sent to the client by the server (ie: the server says what date/time to expire the cookie) but the client then decides when it expires by comparing the expiry time to its internal clock. So if you connect to a server that's ahead of your timezone your cookies may be expiring the moment they're set!

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sam Rusch
    I am having problems with cookies again. I have this code:
    PHP Code:
    setcookie('Nathan','blah',time()+3600); 
    Thank you.
    You server doesn't know what time it is.

    Here are the headers it sent out this morning, January 5 at 15:50 GMT:

    Code:
    telnet> open samrusch.com 80
    Trying 209.59.134.2...
    Connected to samrusch.com.
    Escape character is '^]'.
    get /cookieset.php HTTP/1.1
    Host: samrusch.com
    
    HTTP/1.1 200 OK
    Date: Wed, 04 Jan 2006 08:50:36 GMT
    Server: Apache/2.0.51 (Fedora)
    X-Powered-By: PHP/4.3.10
    Set-Cookie: Nathan=blah; expires=Wed, 04-Jan-2006 09:50:48 GMT
    Content-Length: 52
    Connection: close
    Content-Type: text/html
    
    Please check to see if the cookie "Nathan" was set.

  4. #4
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OS/X 10.3.9 (all updates) --- Cookie did not get set, even after changing safari prefs to accept all cookies.

    fyi, - good luck!
    intragenesis, llc professional web & graphic design

  5. #5
    SitePoint Addict
    Join Date
    Oct 2005
    Location
    Home
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jonoxer
    Was set correctly in my browser (where "correctly" means the value was "blah"!). Browser and OS shouldn't be relevant unless the cookies are being blocked by a specific browser setting, but you may need to check whether you have any time issues: you're setting the expiry period to "now +3600" but that may not be enough if there's a timezone mismatch between your computer and the server. One of the annoying things about cookies is that the expiry time is sent to the client by the server (ie: the server says what date/time to expire the cookie) but the client then decides when it expires by comparing the expiry time to its internal clock. So if you connect to a server that's ahead of your timezone your cookies may be expiring the moment they're set!
    Ah, thanks, I will check this out. Thanks for the help, you along with everyone else.

  6. #6
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I might use a cookie for a "remember me" for member log-ins. Otherwise, the only usefull thing I can find with cookies is when a temporary cookie set by a session variable.

    I'm seeing a growing trend in users that set their browsers to reject ALL cookies.
    intragenesis, llc professional web & graphic design


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
  •