Setup of multiple variables in cookies. Setting cookie: httpcookie xpcookie = new httpcookie ("param"); XpCookie.values.Add ("YYYY", TEMPYEAR); XPCOOKIE.VALUES.ADD ("mm", tempmonth; xpcookie. VALUES.ADD ("Selflag", Tempflag; XPCookie.Vales.Add ("SelValue", TempValue; Response.AppendCookie (XPCOOKIE);
Receive Cookie:
// Get the cookie value httpcookie getcookie = request.cookies ["param"]; getYear = getCookie.values ["yyyy"]. Tostring (); getMonth = getCookie.Values ["mm"]. Tostring (); flagsel = getCookie .Values ["Selflag"]. TOSTRING (); string valueSel1 = getCookie.Values ["SELVALUE"]. Tostring ();
If it is a single variable: set: httpcookie curcookie = new httpcookie ("pass"); curcookie.value = "yes"; response.appendcookie (CURCOOKIE);
Received: httpcookie curcookie = Request.cookies ["pass"]; if (curcookie == null) {...} else {string curvalue = curcookie.value.trim (); ......}
Both cookies did not set the time expired value, which is that IE turns off cookies automatically deletes if they want to set out time: curcookie.expires = datetime.now.addday (1);