<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          cookie.js輕量級的JavaScript API,用于處理瀏覽器cookie

          聯(lián)合創(chuàng)作 · 2023-09-22 08:57

          一個(gè)簡單,輕量級的JavaScript API,用于處理瀏覽器cookie,它易于使用,具有合理的占用空間(~3kb)(gzip:1.73kb),并且沒有依賴關(guān)系。

           

          cookie APIs

          cookie('test', 'tank', 1)    // Create a cookie that expires 1 days from now
          cookie('test')               // Create a cookie, valid across the entire site
          cookie('test', null)         // Delete cookie `test`
          cookie()                     // Get all cookie
          
          cookie.set('test', 'tank', 1) // ====cookie('test', 'tank', 1)
          cookie.get('test')            // ====cookie('test')
          cookie.remove('test')         // ====cookie('test',null)
          cookie.remove('test3', 'test4') // Delete cookie `test3` and `test4`
          
          cookie.clear()                // Clean all cookie
          cookie.all()                  // Get all cookie

          批量設(shè)置cookie的值

          cookie.set({
             name1: 'value1',
             name2: 'value2'
          });

          Cookie Attributes

          cookie("test","123",{
              "expires": 7,
              "path": '/',
              "domain":""
          });
          cookie({"test":"123"},{
              "expires": 7,
              "path": '/',
              "domain":""
          });

          通過在最后一個(gè)參數(shù)中傳遞一個(gè)普通對象來單獨(dú)調(diào)用cookie.set(...)。 每次調(diào)用屬性會(huì)覆蓋默認(rèn)屬性。

          示例:

          cookie('name', 'value', { 'expires': 30, 'path': '/', 'domain':'' });
          cookie.get('name')
          cookie.remove('name')

          expires

          定義何時(shí)刪除cookie。 值可以是一個(gè)數(shù)字,它將被解釋為創(chuàng)建時(shí)的天數(shù)或Date實(shí)例。 如果省略,cookie 將成為會(huì)話 cookie。

          cookie('name', 'value', { 'expires': 30 });

          path

          默認(rèn)值: /

          路徑,字符串類型,指示cookie可見的路徑,指定與cookie關(guān)聯(lián)的WEB頁。值可以是一個(gè)目錄,或者是一個(gè)路徑。

          cookie.set('name', 'value', { path: '' });
          cookie.get('name'); // => 'value'
          cookie.remove('name', { path: '' });

          domain

          默認(rèn)值:Cookie僅對創(chuàng)建cookie的頁面的域或子域可見,Internet Explorer除外(請參閱:有關(guān)Internet Explorer默認(rèn)行為的說明。
          ??如果省略域?qū)傩?,它將在IE中顯示為子域。

          指示cookie應(yīng)該可見的有效域。 所有子域都可以看到cookie。

          示例:

          cookie.set('name', 'value', { domain: 'subdomain.website.com' });
          cookie.get('name'); // => undefined (need to read at 'subdomain.website.com')

          secure

          默認(rèn)值:無安全協(xié)議要求。

          無論是 true 還是 false,表明 cookie 傳輸是否需要安全協(xié)議(https)。

          Examples:

          cookie.set('name', 'value', { secure: true });
          cookie.get('name'); // => 'value'
          cookie.remove('name');
          瀏覽 23
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  91av在线免费 | 天天拍夜夜操 | 2020年香蕉在线视频观看拒绝收费 | 青青爽视频| 五月天黄色电影播放 |