EuCookieLawAccept - Cannot store value

2 months ago
Hi

My installation of Nop 4.50.2 has started giving me an error when customers click "Ok" on the Accept of EU Cookie Law.
It sends an alert box with the value "Cannot store value "

In the NopCommerce Log i see this error:
"Error 400. Bad request" on the url:
"https://demo.friliv.dk/eucookielawaccept"

This is the method throwning the error:


public virtual async Task<IActionResult> EuCookieLawAccept()
        {
            if (!_storeInformationSettings.DisplayEuCookieLawWarning)
                //disabled
                return Json(new { stored = false });

            //save setting
            var store = await _storeContext.GetCurrentStoreAsync();
            await _genericAttributeService.SaveAttributeAsync(await _workContext.GetCurrentCustomerAsync(), NopCustomerDefaults.EuCookieLawAcceptedAttribute, true, store.Id);
            return Json(new { stored = true });
        }


Any one knows what to do?

Best regards,
Axel
2 months ago
Check this setting
storeinformationsettings.displayeucookielawwarning

Can you post the entire log message (with call stack)?
2 months ago
New York wrote:
Check this setting
storeinformationsettings.displayeucookielawwarning

Can you post the entire log message (with call stack)?


Hi

The setting for "Display EU cookie law warning" is set to active.
I also think that is the right setting.
.
There is no call stack for the error message, only short message.
Full message is empty.
.
I have been reading about it, and it could have something to do with the client not sending correct antiforgery token, so the server will not accept the call.

Any other ideas?
2 months ago
AxelAndersen wrote:

I have been reading about it, and it could have something to do with the client not sending correct antiforgery token, so the server will not accept the call.


Yes, it could. Is your project customized? In 4.50.2 there were changes related to antiforgery tokens, maybe they didn't get to you.
2 months ago
RomanovM wrote:

I have been reading about it, and it could have something to do with the client not sending correct antiforgery token, so the server will not accept the call.


Yes, it could. Is your project customized? In 4.50.2 there were changes related to antiforgery tokens, maybe they didn't get to you.


There is no custommizations done to standard code, only plugins created.
I see there is a version 4.50.3 now, will that change anything for me?
2 months ago
RE:   4.50.3
Yes, get the latest version.  All 4.50.x versions are compatible.  The minor version updates include bug fixes as per the release notes.
2 months ago
New York wrote:
RE:   4.50.3
Yes, get the latest version.  All 4.50.x versions are compatible.  The minor version updates include bug fixes as per the release notes.


I dont see anything regarding antiforgery token in the release notes for 4.50.3
1 month ago
RomanovM wrote:

I have been reading about it, and it could have something to do with the client not sending correct antiforgery token, so the server will not accept the call.


Yes, it could. Is your project customized? In 4.50.2 there were changes related to antiforgery tokens, maybe they didn't get to you.


Any other ideas?
1 month ago
Not every change is reflected in the release notes.  Since above Maksim points out the code change, you should try the latest version.
1 month ago
AxelAndersen wrote:

There is no custommizations done to standard code, only plugins created.


Make sure file Views/Shared/_Root.Head.cshtml (or Themes/{ThemeName}/Views/Shared/_Root.Head.cshtml if you're using a third-party theme) has this code.
<nop-antiforgery-token />