Displaying Cookie data

6 replies
What is the best way to display specific cookie data on a web page?
For example, I want to display an affiliate's ID# that was stored as
a cookie. Here's a sample URL (not a real site):

http://thewebsiteexample.com/members/?member=1234

=======================================
The Cookie is stored with this data:
=======================================
Name: aff
Content: 1234
Domain: .thewebsiteexample.com
Path: /members/
Send for: Any type of connection
Expires: Wednesday, December 02, 2009, 8:01:19 AM
=======================================


On the web page, I simply want to display the '1234' or whatever
the affiliate number happens to be.

Thanks!
#cookie #data #displaying
  • Profile picture of the author Dan Liptak
    In php use the cookie variable.

    PHP Code:
    echo $_COOKIE["aff"]; 
    {{ DiscussionBoard.errors[1062350].message }}
  • Profile picture of the author Gene Pimentel
    Thanks! I'll try that.
    {{ DiscussionBoard.errors[1062446].message }}
  • Profile picture of the author Gene Pimentel
    That works, but ONLY if the web page is in the directory shown in the "path" mentioned in the cookie (in this case, "Path: /members/").

    I want to be able to display the cookie data on a page that is not in the path mentioned. So even though the cookie was set at
    http://thewebsiteexample.com/members/?member=1234

    I'd like to include the cookie data on a page like...
    http://thewebsiteexample.com/software/page1.php

    Is there an easy solution?

    Thanks!
    {{ DiscussionBoard.errors[1063189].message }}
    • Profile picture of the author Steve Diamond
      Gene, I believe you have to make sure that when the cookie is stored it includes
      Path: /
      rather than
      Path: /members/
      That will mean it's active over the entire range of the domain.

      HTH.

      Steve
      Signature
      Mindfulness training & coaching online
      Reduce stress | Stay focused | Keep positive and balanced
      {{ DiscussionBoard.errors[1063295].message }}
  • Profile picture of the author Gene Pimentel
    That makes sense Steve, but I don't have control over the way the cookie is created. It's part of a membership script. Thanks.
    {{ DiscussionBoard.errors[1063303].message }}
  • Profile picture of the author Gene Pimentel
    I've found a work-around, so no further info needed on this. Thanks for your help!

    Gene
    {{ DiscussionBoard.errors[1063349].message }}

Trending Topics