autologin component doesn't work on remote server

Posted by user606521 on Stack Overflow See other posts from Stack Overflow or by user606521
Published on 2012-06-16T07:49:53Z Indexed on 2012/06/17 9:16 UTC
Read the original article Hit count: 245

Filed under:
|

I am using autologin component from http://milesj.me/code/cakephp/auto-login (v 3.5.1). It works on my localhost WAMP server but fails on remote server.

I am using this settings in beforeFilter() callback:

$this->AutoLogin->settings = array(
            // Model settings
            'model' => 'User',
            'username' => 'username',
            'password' => 'password',

            // Controller settings
            'plugin' => '',
            'controller' => 'users',

            // Cookie settings
            'cookieName' => 'rememberMe',
            'expires' => '+1 month',

            // Process logic
            'active' => true,
            'redirect' => true,
            'requirePrompt' => true
        );

On remote server it simply doesn't autolog users after the browser was closed. I can't figure out what may cause the problem.

-------------------- edit

I figured out what is causing the problem but I don't know how to fix this. First of all cookie is set like this:

$this->Cookie->write('key',array('username' => 'someusername', 'hash' => 'somehash', ...) );

Then it's readed like this:

$cookie = $this->Cookie->read('key');

On my WAMP server $cookie is array('username' => 'someusername', 'hash' => 'somehash', ...) and on remote server returned $cookie is

string(159) "{\"username\":\"YWxlay5iYXJzsdsdZXdza2ldssd21haWwuY29t\",\"password\":\"YWxlazc3ODEy\",\"hash\":\"aa15bffff9ca12cdcgfgb351d8bfg2f370bf458\",\"time\":1339923926}"

and it should be:

array( 'username' => "YWxlay5iYXJzsdsdZXdza2ldssd21haWwuY29t", 'password' => "YWxlazc3ODEy", ...)

Why the retuned cookie is string not array?

© Stack Overflow or respective owner

Related posts about cakephp

Related posts about cakephp-2.0