简体   繁体   中英

Retrieve value of cookie from another page in JavaScript or jquery

I am working on a form http://evmyf.vzhgw.servertrust.com/Articles.asp?ID=257

On the form I have a link called upload logo. It opens a window to upload an image. I have stored the image name that is uploaded in the window in a cookie. The cookie name is UploadFile. I want to retrieve the value of the cookie on the link I mentioned above. How can I do it? Please advise.

On the upload logo page that is the new window, I have created the cookie and stored its value using following code in ASP.

Response.Cookies("UploadFile")=File.FileName
fname=Request.Cookies("UploadFile")
response.write("UploadFile=" & fname)

This library will allow you to grab a cookie using jQuery:

https://github.com/carhartl/jquery-cookie

To retrieve a cookie:

var my_cookie_value = $.cookie('UploadFile');

To create a cookie:

$.cookie('the_cookie', 'the_value');

You should try:

jQuery.cookie(name_of_cookie);

or using a global document.cookie to find Your cookie

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM