Writing cookie to disk

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Wilcox

    Writing cookie to disk

    I am using setcookie() to put a cookie on the visitor's machine. When I do
    so, the cookie is set for that browser session, but not written to disk.
    What am I missing to write it to the disk? Code snippet:

    $cookset = setcookie("orig pbx", $_POST['pbx'], 0)

    Thanks,

    Mike
  • Pedro Graca

    #2
    Re: Writing cookie to disk

    Mike Wilcox wrote:[color=blue]
    > I am using setcookie() to put a cookie on the visitor's machine. When I do
    > so, the cookie is set for that browser session, but not written to disk.
    > What am I missing to write it to the disk?[/color]

    You're missing a review of the setcookie() function, namely its third
    parameter.



    [color=blue]
    > Code snippet:
    >
    > $cookset = setcookie("orig pbx", $_POST['pbx'], 0)[/color]

    Some browsers can be configured to only allow session cookies (or
    convert cookies that expire in the year 2038 to be transformed into
    session cookies).
    --
    Mail to my "From:" address is readable by all at http://www.dodgeit.com/
    == ** ## !! ------------------------------------------------ !! ## ** ==
    TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
    may bypass my spam filter. If it does, I may reply from another address!

    Comment

    • Mike Wilcox

      #3
      Re: Writing cookie to disk

      Pedro Graca <hexkid@dodgeit .com> wrote in
      news:slrncqnf8a .vuv.hexkid@ID-203069.user.uni-berlin.de:
      [color=blue]
      > Mike Wilcox wrote:[color=green]
      >> I am using setcookie() to put a cookie on the visitor's machine. When
      >> I do so, the cookie is set for that browser session, but not written
      >> to disk. What am I missing to write it to the disk?[/color]
      >
      > You're missing a review of the setcookie() function, namely its third
      > parameter.
      >
      > http://www.php.met/setcookie
      >
      >[color=green]
      >> Code snippet:
      >>
      >> $cookset = setcookie("orig pbx", $_POST['pbx'], 0)[/color]
      >
      > Some browsers can be configured to only allow session cookies (or
      > convert cookies that expire in the year 2038 to be transformed into
      > session cookies).[/color]

      That would seem to be the case. Setting it to expire in 120 days has
      done the trick.

      Thanks for the info.

      Mike

      Comment

      • Peter

        #4
        Re: Writing cookie to disk

        Hi
        IUf you don't specify an expiry period and cookie domain it will revert
        to a session cookie.

        Put this in the header and it will write a cookie to disk that expires
        after 1 week


        $days=7;
        $cook_expiry = time()+(60*60*2 4*$days);
        setcookie("cook ie_name",
        "cookie_val ue",
        $cook_expiry,
        "/",
        ".your_cookie_d omain.com");


        Mike Wilcox wrote:[color=blue]
        > I am using setcookie() to put a cookie on the visitor's machine. When I do
        > so, the cookie is set for that browser session, but not written to disk.
        > What am I missing to write it to the disk? Code snippet:
        >
        > $cookset = setcookie("orig pbx", $_POST['pbx'], 0)
        >
        > Thanks,
        >
        > Mike[/color]

        Comment

        Working...