Hi,

You can check if browser cookies are enabled or not by using follow. given
JavaScript functions.
//****** jsfunc.js *******//

function f_ReadCookie(cookieName)
{
    if (cookieName == "" )
    {
         return;
    }
    var theCookie=""+document.cookie+(("/") ? "; path=" + "/" : "") ;
    var ind=theCookie.indexOf(cookieName);
    if (ind==-1 || cookieName=="") return "";
    var ind1=theCookie.indexOf(';',ind);
    if (ind1==-1) ind1=theCookie.length;
    return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
        /**** read cookie ****/

        /***** Cookie Check function call  ****/
        f_WriteCookie("ckTmp","Y"); // write temp. cookie
        sVal = f_ReadCookie("ckTmp"); // read this value again
        if (sVal != "Y")
        {
                return false;
        }
        return true;
}

function f_WriteCookie(name, value)
{
        if (name == "")
        {
                return false;
        }

        if (value != null)
        {
                var curCookie = name + "=" + escape(value) + (("/") ? "; path=" + "/" :
"") //+
                document.cookie = curCookie;
        }
}// write cookie


function f_CheckBrowserCookie()
{ 
        // Cookie Check function call 
        f_WriteCookie("ckTmp","Y"); // write temp. cookie
        sVal = f_ReadCookie("ckTmp"); // read this value again<br>
        if (sVal != "Y")
        {
                return false;
        }
        return true;
}
//****************** Use follow. given function in Onload of Body of HTML file of 
Login page ***************************//
<SCRIPT language="JavaScript">
function CheckBrowserCookie()
{
        if(!f_CheckBrowserCookie())
                alert('Browser cookies are disabled.Please enable them.');
}
</SCRIPT>

// *********** in onload  call it as  below **********//
<body bgcolor="#C7D1F1" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0" 
onLoad="CheckBrowserCookie();">

With these functions you will be able to check if the cookies are enabled or disabled.

Regards,

Umesh.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to