
494
|
Chapter 23: The System.Web Namespace
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Returned By
HttpApplication.Context, System.Web.Security.DefaultAuthenticationEventArgs.Context,
System.Web.Security.FormsAuthenticationEventArgs.Context, System.Web.Security.Passpor-
tAuthenticationEventArgs.Context, System.Web.Security.WindowsAuthenticationEventArgs.
Context, System.Web.Services.WebService.Context, System.Web.UI.Control.Context
Passed To
Multiple types
HttpCookie
System.Web (system.web.dll)
sealed class
Use this class to create a client-side cookie. The HttpCookie constructor takes a string
representing the name of the cookie. After creating a cookie, you can add information
to it in the form of name/value pairs by using the HttpCookieCollection.Add( ) method as
follows: objCookies.Values.Add("Name", "John");. Values can be retrieved by using their name
with a syntax like strName = objCookies.Values["Name"];.
To send the cookie to the client browser as part of the HTTP response, use the
AppendCookie( ) method of the HttpResponse class. This method stores the cookie on the
client browser. You can then retrieve a cookie from the HttpResponse class’s cookie
collection on other pages by using the cookie name, as in Response.Cookies["NameList"].To
ensure compatibility with all browsers, you should not store more than 4096 bytes in a ...