I want to increment a cookie value every time a page is referenced even if the page is loaded from cache. What is the ‘best’ or most concise way to implement this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Stolen from http://www.quirksmode.org/js/cookies.html#script
using it:
as pointed out in the comments, you should cast to an int since cookies are stored and returned as strings. Using
foo++or++foowill actually cast for you, but it’s safer to know exactly what you’re working with: