how to retrieve cookies ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nishika
    New Member
    • Feb 2010
    • 2

    how to retrieve cookies ?

    i have written following code for setting & retrieving cookies:-

    Code:
    $lang = 'french';
    setcookie('TRADE_LANGUAGE', $lang, time()+3600);
    print_r($_COOKIE);
    but while printing it gives only one that is "Array ( [PHPSESSID] => 3p4l3oq93b5tet0 r7lea77tca0 ) "

    i have checked in my browser 2 cookies are been created PHPSESSID & TRADE_LANGUAGE but while printing only one gets printed,

    can someone pls tell what can be issue?

    Thanks,
    nishika
    Last edited by Dormilich; Feb 2 '10, 12:30 PM. Reason: Please use [code] tags when posting code
  • dgreenhouse
    Recognized Expert Contributor
    • May 2008
    • 250

    #2
    The cookie is not going to show up until the second visit to a page on the site.

    In other words...

    1- On page one a cookie is set
    2- The user navigates to a different (or same page)
    3- The cookie that was set on the first visit is now available

    The reason that your PHPSESSID cookie was available is because it was already set.

    It can get more involved than that, but these are the basics.

    3.2 How does a cookie really work?

    Comment

    • nishika
      New Member
      • Feb 2010
      • 2

      #3
      Thanks for response i got the answer
      i reloaded the page so i can use the set cookie :)

      Comment

      Working...