JS Output/Get Cookie

Source: Internet
Author: User

JS Output/Get Cookie

function Setcookie (name, value) {    var days = 365;    var exp = new Date ();    Exp.settime (Exp.gettime () + days * * * * +);    Document.cookie = name + "=" + Escape (value) + "; expires=" + exp.togmtstring ();} function GetCookie (c_name) {    if (Document.cookie.length > 0) {        C_start = document.cookie.indexOf (c_name + "=" );//This is because the passed in parameter is quoted string, so C_name can not be quoted        if (C_start! =-1) {            C_start = C_start + c_name.length + 1;            C_end = Document.cookie.indexOf (";", c_start);//When IndexOf () with 2 parameters, the second represents the location, the argument is a number, the number can be quoted or not (preferably not added)            if ( C_end = =-1) c_end = document.cookie.length;            Return unescape (document.cookie.substring (C_start, C_end));        }    }    Return "";}

  

JS Output/Get Cookie

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.