AnonymousIdentificationModule.ClearAnonymousIdentifier AnonymousIdentificationModule.ClearAnonymousIdentifier AnonymousIdentificationModule.ClearAnonymousIdentifier AnonymousIdentificationModule.ClearAnonymousIdentifier Method

Definition

Clears the anonymous cookie or identifier associated with a session.

public:
 static void ClearAnonymousIdentifier();
public static void ClearAnonymousIdentifier ();
static member ClearAnonymousIdentifier : unit -> unit
Public Shared Sub ClearAnonymousIdentifier ()

Exceptions

Calling ClearAnonymousIdentifier() when the anonymous identification is not enabled.

-or-

The user for the current request is anonymous.

Remarks

The ClearAnonymousIdentifier method removes the anonymous identifier associated with a session on a Web site. Use the ClearAnonymousIdentifier method to remove the anonymous identifier associated with a session when the user switches to an authenticated session associated with a user ID, for example when the MigrateAnonymous event occurs.

Since a new anonymous identifier will be issued immediately if the current anonymous identifier is removed, the ClearAnonymousIdentifier method will throw a NotSupportedException if it is called while the session is identified by an anonymous identifier.

If the site is using cookies, the ClearAnonymousIdentifier method issues a clear cookie to remove the anonymous identifier from the browser. The clear cookie is issued even if an anonymous cookie was not sent on the previous request.

The clear cookie is constructed as follows:

  • If the browser supports empty strings in a cookie, the cookie is issued with the empty string as its value; otherwise, the cookie is issued with "NoCookie" as its value.

  • The values for the cookie name, path, and domain are set to the defaults configured in the Web application's configuration file.

  • The expiration date is set to October 12, 1999.

If the site is using cookieless authentication, and an anonymous identifier is present in the URL, the anonymous identifier is removed from the URL. No other changes are made to the address or query string. After the URL is modified, a redirect is issued to return to the currently executing page.

Applies to