Type: Boolean
Returns True if the visitor has session cookies enabled, False if their session cookies have been disabled.
For users with IE 5.0 and higher, BrowserHawk can also detect the difference between disabled session cookies Vs. disabled persistent cookies. Session cookies are cookies that are destroyed when the browser is closed. Persistent cookies are cookies that are stored on the user’s machine for a period of time as set by the cookie.
To check for disabled session cookies, pass in "cookie_sess" to GetExtendedBrowser or AddProperties prior when calling GetExtendedBrowser. To check for both disabled session and persistent cookies, pass in "cookie_sess, cookie_perm".
To check for disabled persistent cookies, pass in "cookie_perm" to GetExtendedBrowser or AddProperties prior to calling GetExtendedBrowser. If the user has persistent cookies disabled, the CookiesEnabled property will be set to False regardless of whether session cookies are enabled. To check for both disabled session and persistent cookies, pass in "cookie_sess, cookie_perm".
With IE versions prior to 5.0, and any version of Netscape and Opera browsers, there is no difference between disabled session Vs. persistent cookies. This is because IE 5.0 and higher are the only browsers that allow enabled/disabled status to be set differently for each cookie type. Therefore it is irrelevant whether you pass in "cookie_sess" or "cookie_perm" for this check (or "cookie_both") because BrowserHawk will check the browser the same way. In this case all the various cookie check options are synonymous.
Note: Use of this property requires the Professional or Enterprise Edition of BrowserHawk.
Special notes for this property:
If you have a load balanced web farm you must set the CookieDomain property to your root domain (i.e. "mycompany.com") prior to calling GetExtPropertiesEx. Otherwise BrowserHawk will detect cookies as being disabled, even if enabled.
When testing your code to ensure the cookie detection works as you have applied it to your site, you will likely be switching your browser back and forth from accepting to rejecting cookies. Each time you change your settings, be sure to delete your cookies, clear your history, close your browser, and reopen it. While this is obviously not needed for detection in the "real world", you may experience inconsistent testing results otherwise due to previous tests.
When checking for disabled cookies, BrowserHawk first checks to see if the browser is even capable of supporting cookies in the first place, before testing whether they are enabled or not. This way code execution is efficient as possible, and there is no need for you to perform this checking on your own before calling this method. Likewise there is no longer a need to check the BrowserHawk Cookies property, since that property only indicates whether a browser is capable of supporting cookies and not whether they are disabled.
C# Example 1 – If interested only in Session cookie status and not Persistent cookies:
<%
ExtendedOptions options = new ExtendedOptions();
options.AddProperties("cookie_sess");
ExtendedBrowserObj extBrow = BrowserObj.GetExtendedBrowser(options);
%>
<html>
Session cookies: <% Response.Write(extBrow.SessionCookies); %>
</html>
C# Example 2 – If interested in both Session and Persistent cookies status:
<%
ExtendedOptions options = new ExtendedOptions();
options.AddProperties("cookie_both");
ExtendedBrowserObj extBrow = BrowserObj.GetExtendedBrowser(options);
%>
<html>
Session cookies: <% Response.Write(extBrow.SessionCookies); %> <br>
Persistent cookies: <% Response.Write(extBrow.PersistentCookies); %> <br>
</html>
TIP: See the cookies.aspx sample included with your installation for more information.
See Also:
PersistentCookies Property (.NET)