示例#1
0
文件: BasePage.cs 项目: zhangwxyc/BPM
        public HttpCookie SetCookie(UserProfileInfo employee)
        {
            CookieEntity cokc = new CookieEntity();

            cokc.mainCookieName  = cookieEmployeeKey;
            cokc.mainCookieValue = Server.UrlEncode(employee.CHName);

            Dictionary <string, string> childCooks = new Dictionary <string, string>();

            childCooks.Add(cookieEmployeeName, Server.UrlEncode(employee.CHName));
            childCooks.Add(cookieEmployeeEmail, employee.Email);
            childCooks.Add(cookieEmployeeCode, employee.ID.ToString());
            //childCooks.Add(cookieEmployeePost, Server.UrlEncode(employee.Post));
            cokc.childCookies = childCooks;

            return(CookieHelper.SetCookie(cokc));
        }
示例#2
0
        public static HttpCookie SetCookie(CookieEntity cookCls)
        {
            HttpCookie cookie = new HttpCookie(cookCls.mainCookieName);

            cookie.Value = cookCls.mainCookieValue;
            if (string.IsNullOrEmpty(cookCls.domainName))
            {
                cookie.Domain = cookCls.domainName;
            }
            if (cookCls.ExpireDate != null)
            {
                cookie.Expires = (DateTime)cookCls.ExpireDate;
            }
            foreach (KeyValuePair <string, string> entry in cookCls.childCookies)
            {
                cookie[entry.Key] = cookCls.childCookies[entry.Key];
            }
            HttpContext.Current.Response.AppendCookie(cookie);
            return(cookie);
        }