The Power to Create Cookies

The Power to Create Cookies

There isn't any way for Zoho programmers to create and monitor a session, except by registering and having a user log on with their own ID.  This is not practical for many applications where you do not want to impose upon the user.  While Zoho does issue its own cookies we developers don't have any way to read them.



The below snippets can be used to create cookies on the client's computer which will allow us to create sessions, know who is returning, set preferences etc.  It would not be hard to incorporate this in your program.

A typical use would be to use cookies as session monitors and to keep track of user selections.  Global functions that do this are a drain on Zoho's own servers.

Following are the simple Javascript functions for managing cookies.

function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}

By using cookies the power of Zoho applications for the third party Zoho developer increases many fold.  One of the biggest benefits is allowing a layer of security that helps identify a user.  Surely Zoho is already using cookies in their userid functions.