HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

How to check if cookies are enabled

32,556 views November 3, 2015 7:25

Watch on YouTube
Channelkudvenkat

Description from the creator

Link for all dot net and sql server video tutorial playlists
youtube.com/user/kudvenkat/playlists

Link for slides, code samples and text version of the video
csharp-video-tutorials.blogspot.com/2015/02/how…

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?s…

In this video we will discuss, how to check if cookies are enabled.

Most websites rely on browser cookies being enabled. For example, if you have disabled cookies and if you try to log into gmail.com, you will receive an error message saying - Oops! Your browser seems to have cookies disabled. Make sure cookies are enabled or try opening a new browser window.

The following JavaScript code detects if cookies are enabled. Most modern browser's support navigator.cookieEnabled property. This property returns true if cookies are enabled and false if cookies are disabled. Some old browsers don't support this property. For those browsers that don't support navigator.cookieEnabled property, we are setting "mytestcookie" and then reading again to make sure cookies are enabled. If we are not able to read "mytestcookie" then we know that cookies are disabled.

[div id="msg"][/div]
[script type="text/javascript"]
function cookiesEnabled()
{
var cookiesEnabled = (navigator.cookieEnabled) ? true : false;

if (typeof navigator.cookieEnabled == "undefined" && !cookiesEnabled)
{
document.cookie = "mytestcookie";
cookiesEnabled = (document.cookie.indexOf("mytestcookie") != -1) ? true : false;
}

return cookiesEnabled;
}

if (cookiesEnabled())
{
document.getElementById("msg").innerHTML = "Cookies enabled";
}
else
{
document.getElementById("msg").innerHTML = "Cookies disabled";
}
[/script]

About this tutorial

kudvenkat published this 7:25 video tutorial on November 3, 2015. It has been watched 32,556 times on YouTube.

Channel
kudvenkat
Category
Education
Duration
7:25
Published
November 3, 2015
Views
32,556
Likes
128

Tags

Share

This tutorial in other languages