Memory App

Cookies allow your application to store a small text file on client Web broweser.

    // Set a cookie on the client
    setcookie('hide_menu', '1');

    if ($_COOKIE['hide_menu'] == 1) {
        echo 'Hide Menu';
You can provide an expiration time.

    setcookie('hide_menu', '1', 3600); // 1 hour
Cookies values must be scalar

    setcookie('hide_menu', array());
    // Warning: setcookie() expects parameter 2 to be string
There are three more arguments:

    // path - where cookie will be accesible
    // domain - allowed domani
    // secure - the browser only send cookie in case of HTTPS
    setcookie('hide_menu', '1', 86400, '/path/', '', 1); // a day
You can create arrays using the same array.

    setcookie('test[0]', "foo");
    setcookie('test[1]', "bar");
To delete a cookie, set time negative

    setcookie("hide_menu", false, -3600);
Keep in mind that the amount of storage available is severely limited therefore, use sessions instead. If you want to set cookie for another domain, it can not be done.

0/0 (80)  
Not Logged