<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                使用微信考勤,每次使用[微信企業號開發:微信用戶信息和web網頁的session的關系](http://blog.csdn.net/xuexiaodong009/article/details/47747569)這個里邊的方法,調用微信的接口,有點慢,微信官方也推薦使用Cookies,但如何使用Cookies,自己卻一直沒有搞清楚。 原來一直以為在服務端獲取客戶端的數據有兩個方法,一種就是查詢字符串放在URL上,一種就是放在form中,post提交,自己以前也使用過但主要是在客戶端使用,從來沒法把 Cookies中的數據直接提交到服務端,即使有也是通過把Cookies中的數據讀取出來后放入form中的隱藏字段,然后post到服務端。 顯然微信考勤這類其實就是一個URL,在進入URL的過程中,沒有什么post數據的過程。只有進入URL之后再通過用戶提交,或者ajax提交。總之似乎沒法直接把Cookies中的數據直接提交給服務端。似乎陷入了僵局。于是自己再一次研究了Cookies,發現Cookies似乎是主動提交到服務端的,但和post是提交的位置不一樣,當然我沒有找到相關文檔,是測試發現的。只要自己設定了Cookies,每次進入URL都會提交Cookies,自然就可以在服務端讀取到Cookies的值了。這時才真正明白記住密碼的真正實現原理。并不是把Cookies的值讀出來,放入隱藏字段,然后通過ajax提交到服務端,就可以免登陸了。 ![](https://box.kancloud.cn/2016-01-14_569757de5bee5.jpg) 可以看到Cookies的數據到了服務端,sessionID也是通過Cookies這種方式傳到服務端的。 前端js讀取,設置Cookies的方法: ~~~ function setCookie(name, value) {//兩個參數,一個是cookie的名子,一個是值 var Days = 30; //此 cookie 將被保存 30 天 var exp = new Date(); //new Date("December 31, 9998"); exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000); document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString(); } function getCookie(name) {//取cookies函數 var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)")); if (arr != null) return unescape(arr[2]); return null; } ~~~ CSharp服務端操作Cookies: 設置Cookies ~~~ HttpCookie cookie = new HttpCookie("UserCode", username); cookie.Expires = DateTime.Now.AddDays(10);// (365 * 24 * 3600); this.Response.AppendCookie(cookie); HttpCookie cookieDeviceId = new HttpCookie("DeviceId", rt.DeviceId); cookieDeviceId.Expires = DateTime.Now.AddDays(10);// (365 * 24 * 3600); this.Response.AppendCookie(cookieDeviceId); ~~~ 讀取Cookies: ~~~ HttpCookie ttHttpCookie = this.Request.Cookies.Get("UserCode"); HttpCookie ttHttpCookieDeviceId = this.Request.Cookies.Get("DeviceId"); string code = Request.QueryString["code"]; if (ttHttpCookie == null || ttHttpCookieDeviceId == null) { WeiApi(code); } else { string username = ttHttpCookie.Value; string DeviceId = ttHttpCookieDeviceId.Value; if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(DeviceId)) { WeiApi(code); } else { new AppException("讀取Cookies UserCode=" + username + ",DeviceId=" + DeviceId); initSession(username, DeviceId); } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看