Jump to content

Cookies


dalawh

Recommended Posts

I was looking at http://www.w3schools.com/js/js_cookies.asp and I was wondering if there was something more detailed on cookies. How do cookies look like? Are they just like a text in a document? If you look at the getCookie function, it only gets one line from the cookie, which I assume is because of the setCookie function only creates 1 line, but isn't a cookie normally larger or are cookies individually defined/created by the web designer and not the browser itself? What does "unescape(y)" do?

Link to comment
Share on other sites

Cookies are a array called $_COOKIE (all caps). One of the many ways they can be viewed is with a var_dump().

Edited by niche
Link to comment
Share on other sites

Cookies are a array called $_COOKIE (all caps). One of the many ways they can be viewed is with a var_dump().
Isn't $_COOKIE php? Is there a better tutorial any where? Can you tell me a bit more on var_dump()?
Link to comment
Share on other sites

Yeah... those are PHP stuff... it's where cookies make most sense anyway.All cookies for a domain look like a single string. Browsers store one cookie file per domain, and send the contents of this file on every HTTP request to that domain. In JavaScript, you have the whole file in "document.cookie", and the very page you linked to shows how to parse the contents in order to get a particular value.In PHP, you don't need to parse the file. It's automatically parsed into the $_COOKIE array in a fashion similar to what the W3Schools page shows.

Link to comment
Share on other sites

If you want to know what the cookie actually is, it's typically just stored as a text file that contains the data (name and value) that you set. When the browser sends it to the server it sends the name and value that was stored on your computer for that website.

  • Like 1
Link to comment
Share on other sites

Sorry about that. I clicked-in from the recent topics heading. It didn't even occur to me to check which forum I was in. Please excuse me.

Link to comment
Share on other sites

The name is encoded and the value is encoded, to prevent characters like "=" or "&" from interfering with correct parsing of the cookie string.

Link to comment
Share on other sites

The name is encoded and the value is encoded, to prevent characters like "=" or "&" from interfering with correct parsing of the cookie string.
Oh okay. Thanks for explaining this. Any way I can close this thread? Edited by dalawh
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...