• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Setting a cookie

Mike Creuzer

Well-known member
#1
Hey all,

Was wondering how to set a cookie using (I'm assuming there is a built-in function) XenForo, as I was hoping to be able to do it without loading the jQuery cookie plugin. Could someone provide a basic example of doing this (I'm not the best javascript developer in the world, I'm not quite a master yet :p).

Thanks!
 

Onimua

Well-known member
#2
How are you wanting to do it? It could be done via PHP:
PHP:
XenForo_Helper_Cookie::setCookie('cookieName', cookieinfo, timeout);
XenForo_Helper_Cookie::deleteCookie('cookieName');
 

Mike Creuzer

Well-known member
#3
Hey there, I want to do with javascript. I can do it the long way or I can import jQuery cookie plugin, but figured there was a way to do it with XenForo and just thought I'd found out how :)
 

Mike Creuzer

Well-known member
#5
Ah thanks a lot, $.setCookie() and $.getCookie() :D, I couldn't find it until I beautified the xenforo.js file, thanks a lot! (think my find function was buggy)