HttpHelper萬能架構GetMergeCookie的問題

來源:互聯網
上載者:User

標籤:合并   php   merger   ber   visit   com   ted   pos   string   

用萬能架構寫了一個DZ帶驗證碼POST登入一直錯誤 http://www.sufeinet.com/thread-17795-1-1.html 調試半天發現是架構GetMergeCookie的問題,,,真坑。。。

 

OldCookie

 

F9ZL_2132_saltkey=oHLnJLwj;
F9ZL_2132_lastvisit=1477040054;F9ZL_2132_sid=ZsTR8p;F9ZL_2132_lastact=1477043654%09member.php%09logging;F9ZL_2132_pc_size_c=0;F9ZL_2132_stats_qc_reg=deleted

NewCookie

F9ZL_2132_lastact=1477043656%09misc.php%09seccode

 

HttpHelper.GetMergeCookie 合并更新後  導致有兩個 F9ZL_2132_lastact=

F9ZL_2132_saltkey=oHLnJLwj ;F9ZL_2132_lastvisit=1477040054 ;F9ZL_2132_sid=ZsTR8p ;F9ZL_2132_lastact=1477043654%09member.php%09logging ;F9ZL_2132_pc_size_c=0 ;F9ZL_2132_stats_qc_reg=deleted ;F9ZL_2132_lastact=1477043656%09misc.php%09seccode

 

正確更新:

F9ZL_2132_saltkey=oHLnJLwj;F9ZL_2132_lastvisit=1477040054;F9ZL_2132_sid=ZsTR8p;F9ZL_2132_lastact=1477043656%09misc.php%09seccode;F9ZL_2132_pc_size_c=0;F9ZL_2132_stats_qc_reg=deleted

 

找了個方法解決了這個,帳號也登入成功了。勿噴,,不知道架構那個是不是BUG。。。

public static string MergerCookies(string OldCookie, string NewCookie)       {           if (!string.IsNullOrEmpty(OldCookie) && !string.IsNullOrEmpty(NewCookie))           {               if (OldCookie == NewCookie) return OldCookie;               else               {                   List<string> Old = new List<String>(OldCookie.Split(‘;‘));                   List<string> New = new List<String>(NewCookie.Split(‘;‘));                   foreach (string n in New)                   {                       foreach (string o in Old)                       {                           if (o == n || o.Split(‘=‘)[0] == n.Split(‘=‘)[0])                           {                               Old.Remove(o);                               break;                           }                       }                   }                   List<string> list = new List<string>(Old);                   list.AddRange(New);                   return string.Join(";", list.ToArray());               }           }           else if (!string.IsNullOrEmpty(OldCookie)) return OldCookie;           else if (!string.IsNullOrEmpty(NewCookie)) return NewCookie;           else return "";       }

 

HttpHelper萬能架構GetMergeCookie的問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.