View Full Version : How to check if a cookie exists

2 Jul 2010, 6:39 AM
Ok...so this might be kiddy stuff but I'm pretty new to Ext and just can't figure out how to properly check if a cookie exists or not.

My code looks like:

if(Ext.state.Manager.get('firstVisit', true) == true)
var messageCookie = new Ext.state.CookieProvider({
path: "/",
expires: new Date(new Date().getTime()+(1000*60*60*24*365*30)), //30 years
domain: "test.com",
secure: true

Ext.state.Manager.set('firstVisit', false);

alert('created a new cookie');

The problem is that my test alert comes up each time I come to the page and I know the cookie has already been set. What am I missing that's probably blatantly obvious?

2 Jul 2010, 6:58 AM
For such basic Cookie stuff you should be using Ext.util.Cookie instead of Ext.state.CookieProvider.

2 Jul 2010, 8:06 AM
I've found going old school has basically solved the problem. Thought Ext had a super slick way of handling it.

22 Jul 2010, 9:57 AM