Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

read cookie value in jquery

Tags:

jquery

cookies

I have called one php page inside the iframe

I have stored some values in cookies.I want to read that cookies values from that page to other page.

I used jQuery to read cookie.

var value = $.cookie('artname');

'artname' is the cookie name.

But it displaying null value because cookies path is different,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'); Its still showing me the same.

how can I get value of cookie?

like image 647
user959128 Avatar asked Sep 22 '11 12:09

user959128


People also ask

How do I retrieve data from cookies?

Read cookie using JavaScript: This function retrieves the cookie data stored in the browser. The cookie string is automatically encoded while sending it from the server to the browser. Hence it needs to be decoded before the actual data can be retrieved.

What does jQuery cookie do?

cookie. A simple, lightweight jQuery plugin for reading, writing and deleting cookies.

How check cookie is set or not in jQuery?

If this is the case, then you can actually check if a user has enabled cookies or not using the following straightforward jQuery snippet: $(document). ready(function() { var dt = new Date(); dt. setSeconds(dt.


1 Answers

just use the path property

$.cookie("example",  { path: '/' });

http://www.electrictoolbox.com/jquery-cookies/

cheers

like image 131
nWorx Avatar answered Oct 07 '22 14:10

nWorx