# Cookie checker

**URL:** https://forum.kirupa.com/t/cookie-checker/216846
**Category:** Uncategorized
**Created:** [February 21, 2007, 12:57am UTC](https://forum.kirupa.com/t/cookie-checker/216846 "2007-02-21T00:57:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nburlington](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nburlington/32/1365_2.png) [@nburlington](https://forum.kirupa.com/u/nburlington)
#### Post date: [February 21, 2007, 12:57am UTC](https://forum.kirupa.com/t/cookie-checker/216846/1 "2007-02-21T00:57:43Z")

</div>

can someone point me to javascript that will check for a cookie and if its not there, set one one up? I have this function but I don’t know how to set it to search for the cookie first before making one.

```auto
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

```

Any help or just a point in the right direction would be greatly appreciated.
