Giter VIP home page Giter VIP logo

magento-remember-me's People

Contributors

clockworkgeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

wnuken

magento-remember-me's Issues

Cookie Expiration Not Honored

Thanks for the great extension!

I'm having an issue with the cookies expiring before they should. I've verified that the 'frontend' cookie has an expiration date 1 year in the future but, regardless, the cookies are still expiring. This happens on a myriad of different devices/browsers so I don't think it's an issue with browser settings. I'm using Magento EE 1.9.1.1.

Steps I've Taken

  • I installed the extension and verified the extension is recognized and is run.
  • I placed php_value session.gc_maxlifetime 2592000 in the site's .htaccess file.
  • Viewed cookie expiration value within the browser to verify the expiration is set to 1 year from the time the cookie was created.

After doing the above, I modified the Cookie.php file provided in the extension to include some logging functionality so we can see what is going on.

Cookie.php

<?php
/**
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 *
 *
 * @category   Customer
 * @package    Clockworkgeek_Rememberme
 * @author     Daniel Deady <[email protected]>
 * @copyright  Copyright (c) 2010, Daniel Deady
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

class Clockworkgeek_Rememberme_Model_Cookie extends Mage_Core_Model_Cookie
{

    /**
     * Set cookie
     * Override period if asked to
     *
     * @param string $name The cookie name
     * @param string $value The cookie value
     * @param int $period Lifetime period
     * @param string $path
     * @param string $domain
     * @param int|bool $secure
     * @return Mage_Core_Model_Cookie
     */
    public function set($name, $value, $period = null, $path = null, $domain = null, $secure = null, $httponly = null)
    {
        if (is_null($period)) {
            Mage::log('Setting cookie ' . $name . ':');
            Mage::log("set($name, $value, $period, $path, $domain, $secure, $httponly)");
            // use $_SESSION directly as session classes may not be initialised yet
            $session = ( isset($_SESSION['rememberme']) ? (bool)$_SESSION['rememberme'] : false );
            $login = Mage::app()->getRequest()->getPost('login');
            $rememberme = ( isset($login['rememberme']) ? (bool)$login['rememberme'] : false );
            $period = $session || $rememberme; // true = one year
        }

        Mage::log("parent::set($name, $value, $period, $path, $domain, $secure, $httponly)");
        return parent::set($name, $value, $period, $path, $domain, $secure, $httponly);
    }

    /**
     * Add our flag on login
     */
    public function setSessionRemembrance()
    {
        if (isset($_SESSION) && !isset($_SESSION['rememberme'])) {
            $login = Mage::app()->getRequest()->getPost('login');
            $_SESSION['rememberme'] = isset($login['rememberme']) && $login['rememberme'];
            Mage::log('setSessionRemembrance() --> $_SESSION[rememberme] = ' . $_SESSION['rememberme']);
        }
    }

    /**
     * Remove our flag on logout
     */
    public function unsetSessionRemembrance()
    {
        Mage::log('unsetSessionRemembrance()');
        if (isset($_SESSION['rememberme'])) unset($_SESSION['rememberme']);
    }

}

Log Output

I then ran a couple of different scenarios. The log output is below:

No 'Remember Me' Login

Setting cookie frontend:
set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
parent::set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
setSessionRemembrance() --> $_SESSION[rememberme] =
Setting cookie frontend:
set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
parent::set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
Setting cookie frontend:
set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
parent::set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )

No 'Remember Me' Logout

Setting cookie frontend:
set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
parent::set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
unsetSessionRemembrance()
Setting cookie frontend:
set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
parent::set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )

With 'Remember Me' Login

Setting cookie frontend:
set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
parent::set(frontend, 0r3kd363akl2b49smcja14peh2, 1, , , , )
setSessionRemembrance() --> $_SESSION[rememberme] = 1
Setting cookie frontend:
set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
parent::set(frontend, 0r3kd363akl2b49smcja14peh2, 1, , , , )
Setting cookie frontend:
set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
parent::set(frontend, 0r3kd363akl2b49smcja14peh2, 1, , , , )

With 'Remember Me' Logout

Setting cookie frontend:
set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
parent::set(frontend, 0r3kd363akl2b49smcja14peh2, 1, , , , )
unsetSessionRemembrance()
Setting cookie frontend:
set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )
parent::set(frontend, 0r3kd363akl2b49smcja14peh2, , , , , )

It appears the set() function is being called multiple times when logging in and logging out. Is this normal? After looking at the logs above, do you see any issue with the way the extension is behaving?

Session Cookie Management

Do I need to modify any of the settings for session cookie management within the admin panel at System -> Configuration -> Web -> Session Cookie Management?

Thanks again for the extension!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.