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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:11:46+00:00 2026-05-30T02:11:46+00:00

I have set a cookie with document.cookie . The content settings in Google Chrome

  • 0

I have set a cookie with document.cookie. The content settings in Google Chrome is showing the cookie. However, document.cookie is displaying as a blank string when printed. Why is this happening?

Here is my code

function setCookie(name,value,lifeTime,path,domain,secure){//lifetime in hours
{
         var c_ = name +'='+escape(value)+'; ';

            var life = new Date();
            lifeTime<1&&lifeTime>0?life.setMinutes(life.getMinutes()+lifeTime*60):life.setHours(life.getHours()+lifeTime);
            life = life.toUTCString();
            c_+='expires='+life+"; ";




        c_+= 'domain='+domain+'; ';


        c_ += 'secure=secure; ';//secure 

        c_ += 'path='+path;

        document.cookie = c_;
        alert(document.cookie);
/*Just splitted the code instead of c = 'name='+value+'expires ='+life  etc*/

}
  • 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-30T02:11:48+00:00Added an answer on May 30, 2026 at 2:11 am

    A possible problem with this function is, it always sets a secure cookie. So, if you’ve requested/opened the page with HTTP not HTTPS protocol, the secure cookie won’t be exposed.

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

Sidebar

Related Questions

so i have this problem, i'm using a index.inc.php file to set a cookie
I have a cookie set as yab_uploadmode and it has numeric value ranging from
I have set my cookie in PHP using the following: setcookie(id, 100, time()+100000, /AP,
I have the following code in website1.com: <script type=text/javascript> document.cookie = qwe=1; alert(document.cookie); </script>
I've just discovered that a script that I have to set a cookie does
When I try to read my cookie that I have set something does not
I am trying to set a permanent cookie by JavaScript. I have something like:
I'm trying to do HEAD requests to follow 302 links, however this link: http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNGrJk-F7Dmshmtze2yhifxRsv8sRg&url=http://www.mtv.com/news/articles/1647243/20100907/story.jhtml
Suppose that you have to set 12 cookies, would it be better to store
We have set up a system where notifications get sent to a user with

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.