Pass data using cookie

xiaoxiao2021-03-06  51

First add USING SYSTEM.WEB.SESSIONSTATE reference.

This time you send information:

HttpCookie cookie = new HttpCookie ( "UserCookie"); cookie.Values.Add ( "UserName", tbName.Text); cookie.Values.Add ( "UserPassword", tbPassword.Value.ToString ()); cookie.Values.Add ("Userrole", DS.Tables ["Users"]. Rows [0] ["role"]. TOSTRING ()); response.Appendcookie (cookie); response.redirect ("mainpage.aspx");

This accepts information:

String Sname = Request.cookies ["usercookie"]. values ​​["UserName"]. TOSTRING (); string snrole = request.cookies ["usercookie"]. Values ​​["userrole"]. Tostring ();

转载请注明原文地址:https://www.9cbs.com/read-117524.html

New Post(0)