JavaScript Javascript cookie value is lost after loading another page javascript cookie value read,javascript cookie value,javascript cookie value

I have a page with a hidden form where a value is echoed by php.

With javascript/jQuery I pick up the value and store it in a cookie. The user is redirected to an external page, then is redirected back to my site on a different page. On this page the cookie value is "0" (the value is lost).

Update: The last page is in a directory above the page where the cookie is set. I set the "path" on the cookie but it still doesn't work.

So - first I do the redirect (by submitting a form) , then I set the cookie:

function sendPostRequest(){
    var $ = jQuery;

    document.myform.submit(); //submitting the form

    var now = new Date();
    var time = now.getTime();
    time += 144000 * 1000;
    now.setTime(time);
    document.cookie =
        'member_id=' + $('#member_input').val() + //getting the value, setting the cookie
        '; expires=' + now.toUTCString() +
        '; path=http://domain-name/the-last-page/';

    console.log(document.cookie); //the cookie is set
    alert($('#member_input').val());
} 

The cookie is set as it should after the redirect.

When the user comes back from the external page to the new page , it shows member_id=0 . So the value is lost.

I suspect something is wrong with the "path". I have tried path=/before. The initial page has a path like: http://domain-name/directory/the-first-page/ .

Update 2: Another info that may be relevant is that the intial page is not SSL-encrypted, but the external page is SSL-encrypted, and the final page isn't.

Answer:1

I have a dist folder containing CSS, fonts, JS folder and an index.html file minimized for Vue.js, ready to deploy and use. I want to use Node.js to run this application. How can I set this up to just ...

I have a dist folder containing CSS, fonts, JS folder and an index.html file minimized for Vue.js, ready to deploy and use. I want to use Node.js to run this application. How can I set this up to just ...

  1. deploy application node.js
  2. deploy app nodejs
  3. deploy node application
  4. how to deploy node js application
  5. deploy node application on server
  6. deploy node application to aws
  7. deploy node application to heroku
  8. deploy node application on iis
  9. deploy node application to docker
  10. deploy node application to azure
  11. deploy node application on tomcat
  12. deploy node application with jenkins
  13. deploy node application on windows
  14. deploy node js application on azure
  15. deploy node application to windows server
  16. deploy node application using jenkins
  17. deploy node js application cloud
  18. deploy node js application bitnami
  19. deploy node application npm
  20. deploy node app to heroku

I have placed a csv file in my assets folder for my react app, however, that file is not getting picked up and added to my dist build via webpack (the images are still added as assets to the build but ...

I have placed a csv file in my assets folder for my react app, however, that file is not getting picked up and added to my dist build via webpack (the images are still added as assets to the build but ...

  1. add webpack file
  2. add file to webpack build
  3. add config file webpack

I have an array with objects of unknown depth, like this var objects = [{ id: 1, name: 'foo' }, { id: 2, name: 'bar', childs: [{ id: 3, name: 'baz', childs:...

I have an array with objects of unknown depth, like this var objects = [{ id: 1, name: 'foo' }, { id: 2, name: 'bar', childs: [{ id: 3, name: 'baz', childs:...

  1. lodash recursive filter

I am a learner in java script currently I am going through the regular expression for validating the password field, I want my password field to contain characters and only one number in any place of ...

I am a learner in java script currently I am going through the regular expression for validating the password field, I want my password field to contain characters and only one number in any place of ...

  1. regular expression validation string
  2. regular expression validation in javascript
  3. regular expression validation c#
  4. regular expression validation in c# code behind
  5. regular expression validation in asp.net
  6. regular expression validation in php
  7. regular expression validation for email
  8. regular expression validation online
  9. regular expression validation in java
  10. regular expression validation in angular 8
  11. regular expression validation in jquery
  12. regular expression validation in react js
  13. regular expression validation for phone number
  14. regular expression validation in mvc model
  15. regular expression validation in mvc
  16. regular expression validation for name
  17. regular expression validation in codeigniter
  18. regular expression validation in laravel
  19. regular expression validation angular
  20. regular expression validation in python