Cookie在域中的读写实现顶级域共享

None.gif Cookie在域中的读写实现顶级域共享 
None.gif读写Cookie
ContractedBlock.gifExpandedBlockStart.gif        写入Cookies信息
写入Cookies信息 #region 写入Cookies信息
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//**//**//// <summary>
InBlock.gif        
/// 写入Cookies信息
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        private void WriteCookies(string uname,string upwd)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//写入Cookies中帐户信息
InBlock.gif
//            HttpCookieCollection Colcookies = Request.Cookies;    
InBlock.gif
            Colcookies = Request.Cookies;                        //获得Cookies集合
InBlock.gif
            HttpCookie Cookies = new HttpCookie("IRMEmail");    //创建Cookies
InBlock.gif
            Cookies.Value = uname;            //设置Cookies值
InBlock.gif
            Cookies.Domain = labDomain.Text.Trim();            //设置Cookies域
InBlock.gif
            Colcookies.Add(Cookies);                            //加入Cookies集合
InBlock.gif
            Response.Cookies.Add(Cookies);
InBlock.gif
InBlock.gif            
//写入Cookies中密码信息
InBlock.gif
            Cookies = new HttpCookie("IRMPassword");
InBlock.gif            Cookies.Value 
= upwd;
InBlock.gif            Cookies.Domain 
= labDomain.Text.Trim();
InBlock.gif            Colcookies.Add(Cookies);
InBlock.gif            Response.Cookies.Add(Cookies);
ExpandedSubBlockEnd.gif        }

ExpandedBlockEnd.gif        
#endregion

None.gif
ContractedBlock.gifExpandedBlockStart.gif        读取Cookies信息
读取Cookies信息 #region 读取Cookies信息
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//**//**//// <summary>
InBlock.gif        
/// 读取Cookies信息
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        private void ReadCookies()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            StringBuilder sbText 
= new StringBuilder();
InBlock.gif            Colcookies 
= Request.Cookies;
InBlock.gif            
int CookiesCount = Colcookies.Count;    //Cookies中的键值数目
InBlock.gif
            for(int i=0;i<CookiesCount;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
string strName    = Colcookies[i].Name;
InBlock.gif                
string strValue    = Colcookies[i].Value;
InBlock.gif                
if((strName == "IRMEmail"|| (strName == "IRMPassword"))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    sbText.Append(strName 
+ ":" + strValue);
InBlock.gif                    sbText.Append(
"<br>");
ExpandedSubBlockEnd.gif                }
        
ExpandedSubBlockEnd.gif            }

InBlock.gif            sbText.Append(
"<br>");
InBlock.gif            LblRequest.Text
=sbText.ToString();
ExpandedSubBlockEnd.gif        }

ExpandedBlockEnd.gif        
#endregion
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值