Magento 2 - invalid form key (add/delete from cart)












0















I have serious problems with custom Magento 2 theme and (probably) formkey cashing. I have 2 views of exactly same e-shop.



 - View 1: Luma Theme
- View 2: Custom Theme (Luma child) - overriding layouts, phtml, styles and javascripts


If cache is enabled and flushed everything -> adding/deleting from car works properly. After several minutes specified actions in View 2 (Custom theme) returns 302 status code and Magento redirects user to /cart page.



Now i discovered 3 ways how to "fix" this issue.




  1. Flush cache - only temporary solution for few minutes.

  2. Delete formKey validation from Magento core - totally inappropriate.

  3. Disable cache - affects performance.


I'm struggling with this problem couple of days and I will be glad for any advice.










share|improve this question
















bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • You're trying localhost as the top level domain?

    – Khoa TruongDinh
    Jul 5 '17 at 4:58











  • No, tld is eu or dev. View 1 with Luma works propertly.

    – Higi
    Jul 7 '17 at 5:42
















0















I have serious problems with custom Magento 2 theme and (probably) formkey cashing. I have 2 views of exactly same e-shop.



 - View 1: Luma Theme
- View 2: Custom Theme (Luma child) - overriding layouts, phtml, styles and javascripts


If cache is enabled and flushed everything -> adding/deleting from car works properly. After several minutes specified actions in View 2 (Custom theme) returns 302 status code and Magento redirects user to /cart page.



Now i discovered 3 ways how to "fix" this issue.




  1. Flush cache - only temporary solution for few minutes.

  2. Delete formKey validation from Magento core - totally inappropriate.

  3. Disable cache - affects performance.


I'm struggling with this problem couple of days and I will be glad for any advice.










share|improve this question
















bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • You're trying localhost as the top level domain?

    – Khoa TruongDinh
    Jul 5 '17 at 4:58











  • No, tld is eu or dev. View 1 with Luma works propertly.

    – Higi
    Jul 7 '17 at 5:42














0












0








0


1






I have serious problems with custom Magento 2 theme and (probably) formkey cashing. I have 2 views of exactly same e-shop.



 - View 1: Luma Theme
- View 2: Custom Theme (Luma child) - overriding layouts, phtml, styles and javascripts


If cache is enabled and flushed everything -> adding/deleting from car works properly. After several minutes specified actions in View 2 (Custom theme) returns 302 status code and Magento redirects user to /cart page.



Now i discovered 3 ways how to "fix" this issue.




  1. Flush cache - only temporary solution for few minutes.

  2. Delete formKey validation from Magento core - totally inappropriate.

  3. Disable cache - affects performance.


I'm struggling with this problem couple of days and I will be glad for any advice.










share|improve this question
















I have serious problems with custom Magento 2 theme and (probably) formkey cashing. I have 2 views of exactly same e-shop.



 - View 1: Luma Theme
- View 2: Custom Theme (Luma child) - overriding layouts, phtml, styles and javascripts


If cache is enabled and flushed everything -> adding/deleting from car works properly. After several minutes specified actions in View 2 (Custom theme) returns 302 status code and Magento redirects user to /cart page.



Now i discovered 3 ways how to "fix" this issue.




  1. Flush cache - only temporary solution for few minutes.

  2. Delete formKey validation from Magento core - totally inappropriate.

  3. Disable cache - affects performance.


I'm struggling with this problem couple of days and I will be glad for any advice.







magento2 php cart cache form-key






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 4 '17 at 13:18







Higi

















asked Jul 4 '17 at 12:50









HigiHigi

12




12





bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • You're trying localhost as the top level domain?

    – Khoa TruongDinh
    Jul 5 '17 at 4:58











  • No, tld is eu or dev. View 1 with Luma works propertly.

    – Higi
    Jul 7 '17 at 5:42



















  • You're trying localhost as the top level domain?

    – Khoa TruongDinh
    Jul 5 '17 at 4:58











  • No, tld is eu or dev. View 1 with Luma works propertly.

    – Higi
    Jul 7 '17 at 5:42

















You're trying localhost as the top level domain?

– Khoa TruongDinh
Jul 5 '17 at 4:58





You're trying localhost as the top level domain?

– Khoa TruongDinh
Jul 5 '17 at 4:58













No, tld is eu or dev. View 1 with Luma works propertly.

– Higi
Jul 7 '17 at 5:42





No, tld is eu or dev. View 1 with Luma works propertly.

– Higi
Jul 7 '17 at 5:42










1 Answer
1






active

oldest

votes


















0














Magento 2 - invalid form key occurs before of 2 reasons.



1) check your view source page, generated form_key and passing form_key are same. if not same need to fix it.



2) increase php_value max_input_vars 75000. Check your error log surely max_input_vars reached error will through.



Hope it will helpful for you






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f181985%2fmagento-2-invalid-form-key-add-delete-from-cart%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Magento 2 - invalid form key occurs before of 2 reasons.



    1) check your view source page, generated form_key and passing form_key are same. if not same need to fix it.



    2) increase php_value max_input_vars 75000. Check your error log surely max_input_vars reached error will through.



    Hope it will helpful for you






    share|improve this answer




























      0














      Magento 2 - invalid form key occurs before of 2 reasons.



      1) check your view source page, generated form_key and passing form_key are same. if not same need to fix it.



      2) increase php_value max_input_vars 75000. Check your error log surely max_input_vars reached error will through.



      Hope it will helpful for you






      share|improve this answer


























        0












        0








        0







        Magento 2 - invalid form key occurs before of 2 reasons.



        1) check your view source page, generated form_key and passing form_key are same. if not same need to fix it.



        2) increase php_value max_input_vars 75000. Check your error log surely max_input_vars reached error will through.



        Hope it will helpful for you






        share|improve this answer













        Magento 2 - invalid form key occurs before of 2 reasons.



        1) check your view source page, generated form_key and passing form_key are same. if not same need to fix it.



        2) increase php_value max_input_vars 75000. Check your error log surely max_input_vars reached error will through.



        Hope it will helpful for you







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 15 '17 at 17:36









        Rama Chandran MRama Chandran M

        2,71181430




        2,71181430






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f181985%2fmagento-2-invalid-form-key-add-delete-from-cart%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Polycentropodidae

            Magento 2 Error message: Invalid state change requested

            Paulmy