用万能框架写了一个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 ""; }
时间: 2024-11-05 03:32:13