so i have this problem, i’m using a index.inc.php file to set a cookie and this is a must.
The problem of setting a cookie with server-side language is that it will not take effect on the first load. The javascript is on the template file index.tpl (Using XTemplate), the COOKIE2 and COOKIE3 are values defined on the PHP, they are cookie values, but on the first load, always empty.
var ligarei = getCookie('ligarei');
if(ligarei != "nao"){
var cookie2 = {COOKIE2};
var cookie3 = {COOKIE3};
var timeout = cookie3 - cookie2;
var timeout2 = 60 - timeout;
$(document).ready(function() {
if(timeout > 60){
popthat();
}
else if(timeout < 60){
setTimeout("popthat()", timeout2 * 1000);
}
});
}
The first getCookie function is ok, it doesn’t matter if it’s empty or null, but the problem is on the var cookie2 and cookie3, the result after compiled is:
var cookie = ;
And this is giving me a unexpected token error .
Any hints on how to solve this?
Thanks very much.
assuming your issue is because you cant in fact change the php code to conform with a simple empty check.