averagejoe77 — 2010-12-08T10:43:27-05:00 — #1
I am trying to set up a page that will allow a user to enter their name into a text field and click a submit button. When the button is clicked, the name that the user entered is passed into a cookie, and displayed on the page at the same time.
However, I am having issues getting the name (i.e. the value of the cookie) to be passed along to other pages within the site as well.
I am using jquery to code the JS with. I have the first page all set up and it works beautifully, but when I try to use the getter for the cookie on the second page I get nothing. I am using a cookie plugin for jquery that I found here.
Any help on tis would be great.
averagejoe77 — 2010-12-08T13:47:54-05:00 — #2
Is it even possible to retrieve a cookie value that is set on one page from another page on the same site?
Or should this just be done with php?
system — 2010-12-08T15:38:18-05:00 — #3
you might be better off storing the username in a php session.
paul_wilkins — 2010-12-08T20:55:42-05:00 — #4
Yes it is. You should ensure that the path the cookie is set with is at a high-enough common location. Typically '/' is used for a site-wide accessible cookie.
The page that you linked to provides detailed information on how to set a path for a cookie.