Make sure to setup your cookie domain name exactly same as how you access from browser(with or without www) And check the following settings in
Magento admin under System > Config > Web
And update like following
Cookie Lifetime: 33600
Cookie Path: /
Cookie Domain: www.yourdomainname.com
Use HTTP Only: No
Cookie Restriction Mode: No
This should fix your problem(Clear your browser cookie for one last time and check)
If this doesn't work still your server environment and session/cookie saving doesn'tmatch like magento needed. So you may need to un-comment domain settings in
app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
Around #95 from
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
To
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
// 'domain' => $cookie->getConfigDomain(),
// 'secure' => $cookie->isSecure(),
// 'httponly' => $cookie->getHttponly()
);
Note:
You can extend this core file to your local and do this and you need to uncomment only the domain,secure,http params not entire cookie params.
I have found a way to make it work.
Step 1: Configure in the Magento Config the Cookie Path
to be /
via: System > Configuration > GENERAL > Web > Session Cookie Management
Step 2: Clear all your cookies of the domain or use an 'Incognito' window.
Your previous try was setting extra cookies on the subdir. This made it a mess.
Step 3: Then you can use this script in a subdir:
<?php
error_reporting( E_ALL & ~E_DEPRECATED | E_STRICT );
ini_set('display_errors', 1);
require_once ('../app/Mage.php');
umask(0);
Mage::app('default');
$coreSession = Mage::getSingleton('core/session', array('name'=>'frontend'));
if ( Mage::helper('customer')->isLoggedIn() ) {
echo 'logged in';
} else {
echo 'not logged in!';
}
You can check your browser cookies. If you have multiple cookies with the same name: this means trouble. Because some cookies are only valid on subdirs, strange things will happen.
Best Answer
I found temporary solution but I think is not right method:
/app/code/Marterosso/Autologin/Controller/Index/Index.php
/app/code/Marterosso/Autologin/etc/frontend/routes.xml
/app/code/Marterosso/Autologin/etc/module.xml
/app/code/Marterosso/Autologin/view/frontend/layout/autologin_index_index.xml
/app/code/Marterosso/Autologin/registration.php
Any other suggestions ?