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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:25:56+00:00 2026-06-09T06:25:56+00:00

I am setting a cookie in Javascript using the following code : setCookie(‘cart_items’,’product_name’); function

  • 0

I am setting a cookie in Javascript using the following code :

setCookie('cart_items','product_name');


function setCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

But the cookie path is not set to root (/) in Chrome. Instead it gets set to the path from where the web page is being executed !!

I tested with IE and FF. It works fine with both these browsers ….

What might be wrong with Chrome or Is it the problem with cookie creation code i am using??

In Chrome ( 16.0.912.63 )

Path: /xxxxxxxx/xxxxxxx

in FF ( 6.0 )

Path: /

in IE (9)

Path: /

  • 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-09T06:25:59+00:00Added an answer on June 9, 2026 at 6:25 am

    The reason this happens is because chrome doesn’t allow setting cookies on local files by default. See this answer for more information: https://stackoverflow.com/a/347997/1324019 (text from answer)

    Chrome doesn’t support cookies for local files (or, like Peter Lyons mentioned, localhost*) unless you start it with the –enable-file-cookies flag. You can read a discussion about it at http://code.google.com/p/chromium/issues/detail?id=535.

    *Chrome does support cookies if you use the local IP address (127.0.0.1) directly. so in the localhost case, that could be an easier workaround.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am setting a value in the cookie using JavaScript and getting the contents
My problem is this. I'm setting a cookie using java script, which contains value
I currently am setting a cookie in my code that last for 10 minutes.
I am getting problem while setting up Session cookie using jersey. is there any
We're supporting legacy code that is dropping a cookie and setting the expiration to
I am using aspx and c# for a setting a authentication cookie for a
I am using Jquery Cookie but am having difficulty setting and retrieving the info.
I have a switcher that is changing backgrounds and setting a cookie using the
I was wondering is there any clear advantage of setting some cookie though JavaScript
I am having a problem with setting cookie with php. I am trying to

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.