jquery cookie

Han Yu dreams of flying 2021-05-03 23:02:50
jquery cookie


Download and import :jquery.cookie.js be based on jquery; First introduced jquery, To introduce :jquery.cookie.js; download :http://plugins.jquery.com/cookie/

<script src="js/jquery.min.js></script><script type="text/javascript" src="js/jquery.cookie.js"></script>

add to cookie

$.cookie('the_cookie', 'the_value', { expires: 7 });$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });// It's indicated here cookie Valid time , Created cookie go by the name of “ persistent cookie (persistent cookie)”. Note that the unit is : God ;// By default , Only settings cookie The web page can read the cookie.// If you want one page to read the settings of another page cookie, You have to set cookie The path of .cookie The path is used to set the ability to read cookie Top level directory for .// Set this path to the root of the site , It can make all the web pages read from each other cookie ( Don't set it like this , Prevent conflict ).

Read cookie


Delete cookie

$.cookie('the_cookie', null); // By passing null As cookie Value 

Optional parameters

$.cookie('the_cookie','the_value',{ expires:7, path:'/', domain:'jquery.com',// establish cookie The domain name of the page secure:true// If true, Then this cookie The transmission of will require a security protocol , for example https}) 

web storage

// Introduce localstorage It's a way to store data without time limit sessionstorage Is a session level storage .// operation localstorage.setItem('fang',18);// Set up localstorage.removeItem('fang');// Delete 
本文为[Han Yu dreams of flying]所创,转载请带上原文链接,感谢

  1. 21. Object oriented foundation "problems and solutions of object traversal"
  2. Discussion on hot micro front end: Google AdWords is a real micro front end
  3. Usecallback and usememo for real performance optimization
  4. 【前端圭臬】十一:从规范看 JavaScript 执行上下文(下)
  5. [front end standard] 11: Javascript execution context from the perspective of specification (2)
  6. Hexagonal六角形架构ReactJS的实现方式 - Janos Pasztor
  7. Transaction of spring's reactive / imperative relational database
  8. The implementation of hexagonal hexagonal reactjs Janos pasztor
  9. HTTP状态码:402 Payment Required需要付款 - mozilla
  10. HTTP status code: 402 payment required - Mozilla
  11. Factory mode, constructor mode and prototype mode
  12. Build the scaffold of react project from scratch (Series 1: encapsulating a request method with cache function based on Axios)
  13. Cocos Quick Start Guide
  14. Comparison of three default configurations of webpack5 modes
  15. A case study of the combination of flutter WebView and Vue
  16. CSS: BFC and IFC
  17. A common error report and solution in Vue combat
  18. JS: this point
  19. JS: prototype chain
  20. JavaScript series -- promise, generator, async and await
  21. JS: event flow
  22. Front end performance optimization: rearrangement and redrawing
  23. JS - deep and shallow copy
  24. JavaScript异步编程3——Promise的链式使用
  25. JavaScript asynchronous programming 3 -- chain use of promise
  26. Vue.js组件的使用
  27. The use of vue.js component
  28. How to judge whether a linked list has links
  29. Element UI custom theme configuration
  30. Text image parallax effect HTML + CSS + JS
  31. Spring的nohttp宣言:消灭http://
  32. Vue3 intermediate guide - composition API
  33. Analysis of URL
  34. These 10 widgets that every developer must know
  35. Spring's nohttp Manifesto: eliminate http://
  36. Learn more about JS prototypes
  37. Refer to await to JS to write an await error handling
  38. A short article will directly let you understand what the event loop mechanism is
  39. Vue3 uses mitt for component communication
  40. Characteristics and thinking of ES6 symbol
  41. Two way linked list: I'm no longer one-way driving
  42. Vue event and form processing
  43. Reactive TraderCloud实时外汇开源交易平台
  44. Reactive tradercloud real time foreign exchange open source trading platform
  45. Node.js REST API的10个最佳实践
  46. Ten best practices of node.js rest API
  47. Fiddler advanced usage
  48. Process from Vue template to render
  49. Promise up (asynchronous or synchronous)
  50. Principle and implementation of promise
  51. Vs code plug in sharing - run code
  52. Vue practical notes (1) introduction of Ant Design
  53. Vue actual combat notes (2) introduction of element plus
  54. Introduction to webpack
  55. Webpack construction process
  56. Vue notes
  57. The experience and lessons of moving from ruby megalith architecture to go microservice
  58. Using leancloud to add artitalk module to hexo blog
  59. Implementation of chrome request filtering extension
  60. Detailed introduction of beer import declaration elements and label quarantine [import knowledge]