MooTools provides us with Cookie, a global object that provides us with a clean and simple access to the cookies on our web browser.

The following code sample shows how simple it is to create a new cookie and how simple it is to read the value of a cookie that already exists.

<!DOCTYPE html>
    <title>cookie demo</title>
    <script type="text/javascript" src="mootools-core-1.4.5-full-nocompat.js"></script>
    <script type="text/javascript">
        function saveCookie()
        function getCookie()
            var key = document.myform.getkey.value;
            document.myform.getvalue.value =;
    <form name="myform">
            key: <input type="text" name="savekey"/>
            value: <input type="text" name="savevalue" />
            <input type="button" value="save" onClick="saveCookie()"/>
            key: <input type="text" name="getkey"/>
            <input type="button" value="get" onClick="getCookie()" />
            <input type="text" name="getvalue"/>

The following video clip overviews this code sample, shows its execution and explains each and every part of it.

You can find more video clips, code samples and presentations for learning how to use the MooTools JavaScript framework in my free courses web site at

Leave a Reply

Your email address will not be published. Required fields are marked *