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.
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 ...
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 ...
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:...
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 ...