I have called one PHP page inside an iframe
I have stored some values in cookies. I want to read those cookies values from that page to other page.
I used jQuery to read the cookie.
var value = $.cookie('artname');
'artname' is the cookie name.
But it is displaying null because the cookie path is different. The path is /v/abcfile/frontend/
.
But the path for the other cookies on the page i am trying to get is /
.
I tried with this:
top.jQuery.cookie('artname');
But it's still showing me the same.
For path ii have tried with:
var value = $.cookie("artname", { path:'/v/vspfiles/frontend/' });
Its still showing me the null value. How can I get value of cookie?
When you save your cookies, set path to "/". Cookie will be available on all pages
$.cookie('artname', 'value', { path:'/'});
This worked for me:
$.cookie.defaults = { path: '/' };
$.cookie("foo", "value" );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.