We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 35303
    • 4 Posts
    Does anyone know why I can’t read my cookie in a snippet anymore, in this 2.1.1 install? $_COOKIE is empty... There has to be a new method.
    MODx session is not good enough, i want my user to see his stuff without login in after closing his browser for a year.

    workaround:
    in snippet cart: include($modx->config[’base_path’].’assets/components/cart/hash.php’);
    in assets/components/cart/hash.php: <?php $hash = $_COOKIE[’hash’]; ?>
    in snippet hash: <?php
    $hash = $_COOKIE[’hash’];
    /* $_COOKIE is empty inside, try hash.php outside */
    if ($hash=="") {include($modx->config[’base_path’].’assets/components/cart/hash.php’);}
    if ($hash=="") {$hash = md5("modx".mt_rand());}/* make new hash, set with js */
    return $hash;