Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of js cookie Operation

2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the example analysis of js cookie operation, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.

CookieObj=function () {}

CookieObj.prototype.clearCookie = function () {

Var now = new Date ()

Var yesterday = new Date (now.getTime ()-1000 * 60 * 60 * 24)

This.setCookie ('co'+this.obj,' cookieValue', yesterday)

This.setCookie ('cs'+this.obj,' cookieValue', yesterday)

}

/ / [Cookie] Sets value in a cookie

CookieObj.prototype.setCookie = function (cookieName, cookieValue, expires, path, domain, secure) {

[xss_clean] =

Escape (cookieName) +'='+ escape (cookieValue)

+ (expires?'; expires=' + expires.toGMTString ():'')

+ (path?'; path=' + path:'')

+ (domain?'; domain=' + domain:'')

+ (secure?'; secure':'')

}

/ / [Cookie] Gets a value from a cookie

CookieObj.prototype.getCookie = function (cookieName) {

Var cookieValue =''

Var posName = [xss_clean] .indexOf (escape (cookieName) +'=')

If (posName! =-1) {

Var posValue = posName + (escape (cookieName) +'=') .length

Var endPos = [xss_clean] .indexOf (';', posValue)

If (endPos! =-1) cookieValue = unescape ([xss_clean] .substring (posValue, endPos))

Else cookieValue = unescape ([xss_clean] .substring (posValue))

}

Return (cookieValue)

}

/ / [Cookie] Returns ids of open nodes as a string

DTree.prototype.updateCookie = function () {

Var str =''

/ / find the key value key to be modified

This.setCookie ('co' + key, str)

}

Thank you for reading this article carefully. I hope the article "sample Analysis of js cookie Operation" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report