Hot answers tagged

38

I had the same problem.... The answer is that your theme does not supply a variable called form_key. Just as stated above I have to add: <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" /> you add it right after <ul class="form-list"> to each one of my login.phtml files for ...


25

IMO the best approach would be to create a class to wrap the cookie creation and then just use it where you want. The Cookie Class {Vendor}/{Module}/Cookie/Example.php <?php namespace Vendor\Module\Cookie; use Magento\Framework\Stdlib\CookieManagerInterface; use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; use Magento\Framework\Session\...


24

Emergency Fix Whether or not this solution works, please try these steps first. You WILL be able to login which means you are on the right page. If you still could not login, your issue is most likely different than the one I'm posting, please proceed at your own risk. Go to your database. If you have phpMyAdmin, do the following: Click on your ...


19

We had to do something similar recently: Cookie Path: / Cookie Domain: .site.com That did the trick in our case.


14

No, that means that sessions are persisted with a cookie, which contains the ID of the session. The only alternative in PHP is a URL parameter like ?SID=d41d8cd98f00b204e9800998ecf8427e where d41d8cd98f00b204e9800998ecf8427e is the session ID. In Short, session data are stored on the server but since HTTP is stateless, a cookie or parameter with the session ...


14

On the Admin menu, select System > Configuration. Then in the panel on the left, under General, click Web. Expand the Session Cookie Management section In the example.com shop, set the following: Set the Cookie Domain to example.com (usually this setting would be .example.com with a dot in front, you might try it without in this case). In the test.example....


13

app/code/Custom/Module/view/frontend/templates/sample.phtml <script type="text/javascript"> require([ 'jquery', 'jquery/jquery.cookie' ], function ($) { $(document).ready(function () { var check_cookie = $.cookie('foo'); // Get Cookie Value var date = new Date(); var minutes = 60; ...


11

Don't develop using localhost as your domain name. I typically use apache to setup a fake custom site at a domain like magento.dev, and then add 127.0.0.1 magento.dev to my hosts file. Beyond working around the cookie problem, this also lets me have an infinite number of sites running locally.


11

The last event dispatched in Magento 1.x before content is rendered is controller_front_send_response_after If there are no extra requirements in observer data that you would need, this one should be perfect for you.


11

in app/code/core/Mage/Page/Block/Html/CookieNotice.php: $block = Mage::getModel('cms/block')->load($blockIdentifier, 'identifier'); Before loading the block, you should set Store ID: $block = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load($blockIdentifier, 'identifier'); You can use your local app/code/...


10

First enable Developer mode in your .htaccess file, add the following at the end of the file: SetEnv MAGE_IS_DEVELOPER_MODE "true" Next edit index.php and uncomment the line: #ini_set('display_errors', 1); Line referenced: https://github.com/OpenMage/magento-mirror/blob/magento-1.9/index.php#L73 Next login via SSH and look for a core dump file under /...


9

Anna makes some good points and her answer will work for a lot of people, but not for me, so I'm posting my own answer. Perhaps my problem was much more fundamental than the one she addresses. My solution was to change my site's domain from example.com to www.example.com. In fact, my research on the internet suggests that the reason sites like Amazon, ...


9

You can store cookie in js file using below method, define([ 'jquery', 'mage/cookies' ], function ($) { $.cookie('cookiename', cookievalue); });


8

This so far is the best solution rather than changing the code elsewhere: Using phpMyAdmin, in your Magento database, look for the core_config_datatable and open it. Click the "Search" tab. Then on the "path" column set the operator to LIKE %...% and the Value to cookie and click the "Go" button to search. After searching, set the value of web/cookie/...


8

A handy trick, to find events fired during a page request / action, is to temporarily edit app/Mage.php and write out the events fired to var/log/system.log public static function dispatchEvent($name, array $data = array()) { Varien_Profiler::start('DISPATCH EVENT:'.$name); $result = self::app()->dispatchEvent($name, $data); ...


8

Ten months later, I'm pretty sure this bug was caused by instantiating a session object too early in Magento's request lifecycle (via an observer). If a session is instantiated too early, the PHP cookie name will be PHPSESSID instead of adminhtml or frontend. This won't halt system operation, but in certain conditional code paths where a cookie's ...


8

This is an article from NovusWeb: http://www.novusweb.com/fix-for-passing-magento-session-ids/ Fix for Passing Magento Session IDs Author: Brett Williams Posted November 9, 2011 Fixing Magento Session IDs We often use shared SSL’s when building e-commerce sites. It’s a convenient way of hosting multiple stores without having to purchase separate SSL ...


8

It may be: cookie setting issue in Chrome browser OR Magento 1.9 is using form key validation at customer loggin and register page. On Post action it check the form key using function _validateFormKey() at controller form key issue: form key missing so add this code in your form <input name="form_key" type="hidden" value="<?php echo ...


8

you need to declare in your class constructor an instance of \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory like this: protected $cookieMetadataFactory; public function __construct( .... \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, .... ) { .... $this->cookieMetadataFactory = $...


8

Having a look at the function: Mage.Cookies.clear = function(name) { if(Mage.Cookies.get(name)){ document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } }; it looks like path and domain are missing. Also the date string is not in the correct format (see: https://stackoverflow.com/questions/11136372/which-date-formats-can-i-use-...


8

Use FireBug plugin to see all request information or print the $_COOKIES auto global variable. Check following information Cookie Name --> Information CART --> The association with your shopping cart. CATEGORY_INFO --> Stores the category info on the page, that allows to display pages more quickly. COMPARE --> The items that you have in the Compare ...


8

In the target.phtml, add js codes like below. Set the cookies <script> require([ 'jquery', 'mage/cookies' ], function ($) { $.cookie('cookie_name', 'value', { path: '/' });//Set the cookies }); </script> If you want get the value from another page, notice the path setting { path: '/' }! Because ...


7

"I always have admin login problems" is a bit vague but here goes Under System > Configuration > Web the settings should be as follows Also set "Session Lifetime (seconds)" under System > Configuration > Admin to a high value like 7200 so you don't need to login repeatedly


7

On the Mage_Customer_Model_Session model's method setCustomerAsLoggedIn() an event customer_login is being dispatched. I guess you need to hook in on that event. You could do this as follows. Add the event to your module's config.xml file (app/code/local/Lpf/ModuleCookie/etc/config.xml): <?xml version="1.0"?> <config> <modules> ...


7

No. The sessions are what keeps your customers logged in. But deleting all the sessions can't be the solution to whatever problem you face. Either it's enough to delete cookies to loose your own session or there's really something broken with the sessions, then you are just fighting symptoms and creating new problems. A warning for everybody who is tempted ...


7

Try it. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cookieManager = $objectManager->get('Magento\Framework\Stdlib\CookieManagerInterface'); // set cookie value $cookieManager->setPublicCookie('custome1', 'custome1'); //get cookie value $cookieManager->getCookie('custome1');


6

The simplest way would probably be to create a Mage instance in your external code, as described here. Once you have access to the Mage object, you can pull up the Customer session model and log a customer in that way. In fact, on the page I linked, they point out a way to do just what you're looking for I believe: $customer = Mage::getModel('customer/...


6

As the issue seems to be cookie related, try increasing the cookie life time to 86400 under Sytem -> Configuration -> Web -> Session and Cookie Management The Reason may be, by default cookie lifetime is set to 3600 (1 hour). But if the end users computer time runs ahead of server’s time, cookies will not get set for Magento frontend as well as ...


6

https is only required on pages that submit data like the checkout page for example. Still, using a https URL for unsecure base url wouldn't hurt If you're worrying about people stealing cookies (session hijacking) go to System > Configuration > Web > Session Validation Settings and enable Validate REMOTE_ADDR [EDIT] - Credits to @AnnaVölkl so if ...


6

If you are working in local setup, Change row web/unsecure/base_url value of localhost to your IP in core_config_data table. localhost can be changed to 127.0.0.1 We can also create a virtual host and use domain like names instead of localhost.


Only top voted, non community-wiki answers of a minimum length are eligible