Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6909703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:43:22+00:00 2026-05-27T08:43:22+00:00

so i have this problem, i’m using a index.inc.php file to set a cookie

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:43:23+00:00Added an answer on May 27, 2026 at 8:43 am

    assuming your issue is because you cant in fact change the php code to conform with a simple empty check.

    var ligarei = getCookie('ligarei');
    if(ligarei != "nao"){
        var cookie2 = {COOKIE2} + 0; // or + "" if it is a string
        var cookie3 = {COOKIE3} + 0;
        var timeout = cookie3 - cookie2;
        var timeout2 = 60 - timeout;
    
        $(document).ready(function() {
            if(timeout > 60){
                popthat();
            }
            else if(timeout < 60){
                setTimeout("popthat()", timeout2 * 1000);
            }
    
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem decomposing a relation schema into a set of schemas that
I have this problem.. I'm receiving data from a client..Using a socket connection. But
I have this problem: I am choosing a file from JFileChooser and if i
I have this problem in my application: Step 1 - create an file (xml)
I have this problem whereby, i have created a user defined function within php.
I can't be the first person to have this problem, I must be missing
I have this problem. I read with BufferedReader text from one system file, this
I have this problem. I read with BufferedReader text from one system file, this
I have this problem: Thread1 may set an auto-reset event, and there are many
I have this problem and I'm trying to solve it using jsfiddle but I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.