Jump to content

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 post
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 post
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 post
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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...