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 8750055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:47:57+00:00 2026-06-13T12:47:57+00:00

I am using jquery cookies plugin, in order to increment the value of the

  • 0

I am using jquery cookies plugin, in order to increment the value of the cookie each time a user comes to a page. I am doing this so I can display something on the first visit, then something different on the second visit and then nothing after that.

So i need to determine if its the user’s first visit, their second visit and all visits after.

var cookieTime = jQuery.cookie('shownDialog');
cookie_value = parseInt(cookieTime);

if (cookieTime != 'true') {         
    jQuery.cookie('shownDialog', '1', 'true', {expires: 7});
    cookie_value ++;
}

else if (cookieTime == 'true' && cookie_value > 0){
    cookie_value ++;
}

This code i’ve been using gets reset every time i refresh the page. Instead of holding the value inside the cookie. I am not sure the best way of retaining the value of the cookie and incrementing it each time as the page gets refreshed?

  • 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-06-13T12:47:58+00:00Added an answer on June 13, 2026 at 12:47 pm

    I don’t think

    jQuery.cookie('shownDialog', '1', 'true', {expires: 7});
    

    is the valid form. It’s supposed to be

    jQuery.cookie(cookiename, cookieval, extra);
    

    Source: https://github.com/carhartl/jquery-cookie

    If you want to check if the cookie is set, check if it’s null.

    // Check if the cookie exists.
    if (jQuery.cookie('shownDialog') == null) {
        // If the cookie doesn't exist, save the cookie with the value of 1
        jQuery.cookie('shownDialog', '1', {expires: 7});
    } else {
        // If the cookie exists, take the value
        var cookie_value = jQuery.cookie('shownDialog');
        // Convert the value to an int to make sure
        cookie_value = parseInt(cookie_value);
        // Add 1 to the cookie_value
        cookie_value++;
    
        // Or make a pretty one liner
        // cookie_value = parseInt(jQuery.cookie('shownDialog')) + 1;
    
        // Save the incremented value to the cookie
        jQuery.cookie('shownDialog', cookie_value, {expires: 7});
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this jquery.cookie plugin and I need to set value to TRUE
I'm currently using jQuery Cookies plugin, and depending on which side of the page
I'm using the jQuery cookie plugin to read/write/delete cookies. I'm using cookies to store
Ok so I am using this, https://github.com/carhartl/jquery-cookie , jquery plugin and I need to
Can the Jquery Cookie plugin only read cookies that it sets? I am using
i'm using the jquery cookie plugin. Everything works fine except the fact that I
how can we save dragged item with cookies. I'm using Jquery with this code
Using the code sample below, how could I utilize the jquery cookie plugin so
I am using the jQuery cookie plugin to set a cookie called 'orderStatus' with
I'm using the jQuery Cookie Plugin on my homepage but it doesn't work in

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.