Check if cookie exists if not create it.

Posted by Ozaki on Stack Overflow See other posts from Stack Overflow or by Ozaki
Published on 2010-05-13T01:56:17Z Indexed on 2010/05/13 2:04 UTC
Read the original article Hit count: 369

Filed under:
|
|
|
|

TLDR: Want to check if cookie exists, if it doesn't create it.


Am using jquery1.4.2 and jquery cookie,

I know this is probably very simple but I just cant get my head right at the moment.

I want to:

  1. Check to see if a cookie with name of "query" exists
  2. If so nothing.
  3. If not create a cookie "query" with a value of 1.

But only if it doesn't already exist.

Thanks in advance

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery