MY mENU


Friday 28 September 2012

What is Coockie

Storing a user's information in a cookie can be really useful, but it can also be incredibly frustrating if it's not working! One of the most common mistakes made with cookies is sending them after some code has already been sent.
The code doesn't have to be substantial, a simple at the top of your document before the cookies will mess things up! You should always include your cookies BEFORE any code is sent to the browser.

Why aren't my cookies working?


PHP cookies are a relatively simple way of tracking users by storing information in their browser. Here are the most common reasons a cookie isn't working.
 If your cookies aren't being set, one very common problem is that something is being sent to the browser before the cookie. The cookies need to be in the header and come before any HTML. For example:
 
 
 My Page
  
This code won't work, because you are sending the data (the and other tags) to the browser before the cookie. Instead you should use something like this:
 
 
 
 My Page 
If the problem is that the cookies work for most users but some users are having problems with them, it may be that those particular users have cookies disabled in their browsers. This is not a problem with your code at all, just a user's personal preference.