A cookie is a small object allows servers to store users information on user machine. Cookies are stored in the partition assigned to the web servers domain. All cookies for that domain are sent in every request to that web server. When a user visits a page, his name can be stored in a cookie. Next time when user visits, the cookie recognizes user on the server. Cookies help in to identify user uniquely for session management.
<TITLE>Example to detect Cookie Support</TITLE>
var cookieEnabled=(navigator.cookieEnabled)? true : false
document.writeln("<b>cookieEnabled status </b>–"+cookieEnabled);
//if (cookieEnabled) //if cookies are enabled on client’s browser
- Save the file as cookiesupportexample.html in your system.
- Just open the file in the browser, you will see the below picture in the browser. Note that the browser must support HTML specification.
When the execution process is completed successfully we will get the following output, displaying if the cookie is enabled or not: