Hot answers tagged

39

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 ...


32

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 ...


30

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\...


20

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


18

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 ...


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 ...


13

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....


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/...


11

In the target.phtml, add js codes like below. Set the cookies <script> require([ 'jquery', 'jquery/jquery.cookie' ], function ($) { $.cookie('cookie_name', 'value', { expires: 7, path: '/' });//Set the cookies }); </script> jquery/jquery.cookie is defined in the file lib/web/jquery/jquery.cookie.js. Below is ...


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 /...


10

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


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, ...


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 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

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

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 ...


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

Try following: Copy file to your frontend theme and update text as you want. FROM: vendor/magento/module-cookie/view/frontend/templates/html/notices.phtml TO: app/design/frontend/[VendorName]/[themename]/Magento_Cookie/templates/html/notices.phtml


7

Configure another domain for skin and media check that the cookie domain is configured that way, that the cookies are not send along these domains Make sure, that you don't get a problem with the JS due to "same origin policy" UPDATE set the media, skin and js url to your new domain: System > Config > Web > Unsecure/Secure > Base Media URL System > ...


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

You need manage dependencies with requirejs: require([ 'jquery', 'jquery/jquery.cookie', 'domReady!'// wait for dom ready ], function($) { $('#sort_order_by').change(function() { var productUrl = 'product.phtml'; var value = $(this).val(); $.cookie('sortorderby', value); ...


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');


7

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.


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

Create Cookie We will be creating a test controller to create app/code/[Name_Space]/[Your_Module]/Controller/Cookie/Addcookie.php <?php namespace [Name_Space]\[Your_Module]\Controller\Cookie; class Addcookie extends \Magento\Framework\App\Action\Action { const COOKIE_NAME = 'test'; const COOKIE_DURATION = 86400; // lifetime in seconds /** * @var \...


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