Cookies are really the only way in which you can share user data between two non-sequential web pages. Cookies allow you to store data on users’ systems and retrieve it in minutes, hours or even days later. This makes cookies perfect for remembering things like users' login names, which pages they visited last, what they dropped into their shopping carts and when they did so.
Although server-side code is the most robust method of dealing with cookies, sometimes you need to manipulate cookies on the client side. Luckily, JavaScript can read and write cookies in exactly the same way servers do. Though the problem with JavaScript is that reading a cookie requires a little parsing to get them out. Don't worry, I found a nice little function to the job for us.
(read more...)