SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    how to update cookie value in php

    hi how to update my cookies value in php without change expiration date?

    is this possible ? pls suggest your answers

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No. You don't know the expiration date of cookies sent to you, so while you can set another cookie with the same name, you will be changing the expiration.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To create or to update a cookie use PHP function setcookie(). for further reference about this function please visit:
    PHP: setcookie - Manual

  4. #4
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    if we use setcookie, the expiration date also changed i need only to update the value of one cookie without changing the expiration time

  5. #5
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by goldensona View Post
    if we use setcookie, the expiration date also changed i need only to update the value of one cookie without changing the expiration time
    Again, not possible.

    Only the cookie name and value, not its expiration time, is sent with each request.

    You cannot change the value without changing the expiration time unless you know exactly when you previously set that cookie.

    http://www.ietf.org/rfc/rfc2109.txt

  6. #6
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    how to get the expiration date from the cookie

  7. #7
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by goldensona View Post
    how to get the expiration date from the cookie
    Again, not possible.

    Only the cookie name and value, not its expiration time, is sent with each request.

    You cannot change the value without changing the expiration time unless you know exactly when you previously set that cookie.

    http://www.ietf.org/rfc/rfc2109.txt


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
  •