4

I'm on 2.2.1 with custom theme when login failed, message showed up but are not cleared, it showed duplicate, and when login successfully, its still showing in account infomation page enter image description here enter image description here

  • Hi @Dang Nguyen: these many issue are cached in session that reason repeating – Pramod Kharade Jan 4 '18 at 15:04
  • do you have any idea to help me fix that? – Dang Nguyen Jan 4 '18 at 15:22
  • these message are set into session so check condition whether that message is set or not if it is set then reset that message from session. – Pramod Kharade Jan 4 '18 at 15:25
9

Override messages.js in this location:

app/design/frontend/Mastering/itdesire/Magento_Theme/web/js/view/messages.js

    /**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
define([
    'jquery',
    'uiComponent',
    'underscore',
    'Magento_Customer/js/customer-data',
    'jquery/jquery-storageapi'
], function ($, Component, _, customerData) {
    'use strict';

    return Component.extend({
        defaults: {
            cookieMessages: [],
            messages: []
        },

        /** @inheritdoc */
        initialize: function () {
            this._super();

            this.cookieMessages = $.cookieStorage.get('mage-messages');
            this.messages = customerData.get('messages').extend({
                disposableCustomerData: 'messages'
            });

            if (!_.isEmpty(this.messages().messages)) {
                customerData.set('messages', {});
            }

            $.cookieStorage.set('mage-messages', '');

            $(window).on('beforeunload', function () {
                $.cookieStorage.set('mage-messages', '');
            });

        }
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.