How do I create and read a value from cookie?

前端 未结 19 1621
梦如初夏
梦如初夏 2020-11-21 04:42

How can I create and read a value from a cookie in JavaScript?

19条回答
  •  死守一世寂寞
    2020-11-21 05:11

    Here's a code to Get, Set and Delete Cookie in JavaScript.

    function getCookie(name) {
        name = name + "=";
        var cookies = document.cookie.split(';');
        for(var i = 0; i 

    Source: http://mycodingtricks.com/snippets/javascript/javascript-cookies/

提交回复
热议问题