Beginners JavaScript Cookie (1)

Source: Internet
Author: User
Tags domain name access
Introduction to cookie| Beginners

====================================

The problem is that I want to resolve the automatic access http://www.thehungersite.com. This page can limit your access to it once every day (don't forget to click on this link).
So far, the first thing I did at the beginning was to manually select my bookmarks to load this page.

Why not create a simple script for it?
Because I wanted it to work the same way under Netscape and IE, I started learning JavaScript.

Solve

====================================

The theme is simple: Create a page and test if today's page has been loaded,
If it is not loaded, it is linked to http://www.thehungersite.com through it and set
This page serves as the homepage of the browser.

Getting the page and redirecting it is easy, and the question is how to remember that the page has been accessed.

Because JavaScript has no access to files, it seems we can only use cookies.

Cookies are a variable with a size limit, which is associated with a server's domain name,
By default, the lifetime of a cookie is emptied when the browser is closed (note: not when you leave
This page, but you can use a script to change the situation,
After the user closes the browser to enable cookies to be stored, Netscape in the file using all the
Cookies, and IE stores each cookie separately. In addition, different browsers bring some intent
Not, you have to determine whether a user has the cookies turned off in its browser settings.

Everything's fine and good, but now I haven't tested it in IE, calling the sample JavaScript statement:
Cookieexpires = "01-apr-" + nlyear + "GMT";
Document.cookies = cookiename + "=" + Cookievalue + "; expires= "+ cookieexpires;

and then call
document.write (Document.cookie);

The Document.cookie is empty.

------------------------------------------



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.