fatica
September 15, 2021, 1:46am
1
Checked in multiple browsers, private mode etc. Seems to only happen when the page with Matomo installed is IFRAMEd. Any ideas?
piwik.js:12 There was an error setting cookie _pk_ses.1228.158f
. Please check domain and path.
ak @ piwik.js:12
df @ piwik.js:33
cd @ piwik.js:41
cr @ piwik.js:44
b1 @ piwik.js:45
(anonymous) @ piwik.js:61
ch @ piwik.js:50
P.trackPageView @ piwik.js:61
af @ piwik.js:12
ad @ piwik.js:66
addTracker @ piwik.js:68
(anonymous) @ piwik.js:71
(anonymous) @ piwik.js:71
Naser_Aslam
(hafiznaseraslam92@gmail.com)
October 1, 2021, 5:01pm
2
fatica:
IFRAMEd
Hi @fatica ? Did you solve the issue? I am also getting the same issue. I need to use third party website as Iframe. So how to fix the following error.
There was an error setting cookie `_pk_ref.2.1176`. Please check domain and path.
ak @ matomo.js:12
df @ matomo.js:33
cr @ matomo.js:43
b1 @ matomo.js:45
(anonymous) @ matomo.js:61
ch @ matomo.js:50
P.trackPageView @ matomo.js:61
af @ matomo.js:12
ad @ matomo.js:66
addTracker @ matomo.js:68
(anonymous) @ matomo.js:71
(anonymous) @ matomo.js:71
1 Like
Lukas
(Lukas Winkler)
October 1, 2021, 5:16pm
3
Hi to both of you.
This issue has been reported and fixed here:
opened 06:09PM - 27 Aug 21 UTC
closed 03:20PM - 06 Sep 21 UTC
Bug
Regression
I get the error "There was an error setting cookie `mtm_cookie_consent`. Please ā¦ check domain and path." on every page load in my Chrome browser.
I was able to narrow it down to this location in the minified matomo.js:
```
if ((!dt || dt >= 0) && aD(dp) !== dq) {
var dk = "There was an error setting cookie `" + dp + "`. Please check domain and path.";
ak(dk)
}
```
The problem is the second part of the condition. `aD(dp) !== dq` is indeed unequal, but only because the type is not correct. The first part returns `1630087076907` as a string, while the second part returns the same `1630087076907` as an integer.
## Expected Behavior
No console error should be thrown.
## Possible Solution
A typecasting would have to take place before (or a `!=` would have to be set instead of a `!==`).
## Steps to Reproduce (for Bugs)
I don't know why others don't see the error message. I can reproduce the error locally and on prod.
## Your Environment
* Matomo Version: 4.4.1
* PHP Version: 7.2.23
* Browser: Chrome 92
* Operating System: Windows 10
Apart from displaying the message in the console everything works just as it should (so the bug is just displaying the message)
fatica
October 1, 2021, 6:19pm
4
Yes, ensuring full HTTPs, plus the addition of
_paq.push([āsetCookieSameSiteā, āNoneā]);
in the tracking code addressed the issue for me.
Lukas
(Lukas Winkler)
October 1, 2021, 6:21pm
5
Iām not sure what the side effects of [āsetCookieSameSiteā, āNoneā]
are, so Iād recommend to instead either leave the warning alone until 4.5.0 or apply the real fix from
matomo-org:4.x-dev
ā matomo-org:17926-check-cookie-value-type-safe
opened 11:34PM - 29 Aug 21 UTC
### Description:
Fixes #17926
Cookies are string values so if we set a coā¦ okie with an int value we need to check the string value of that int against the set cookie to make sure it was correctly set (otherwise eg '12345' !== 12345 and we log an unnecessary console error)
### Review
* [ ] [Functional review done](https://developer.matomo.org/guides/pull-request-reviews#functional-review-done)
* [ ] [Potential edge cases thought about](https://developer.matomo.org/guides/pull-request-reviews#potential-edge-cases-thought-about) (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
* [ ] [Usability review done](https://developer.matomo.org/guides/pull-request-reviews#usability-review-done) (is anything maybe unclear or think about anything that would cause people to reach out to support)
* [ ] [Security review done](https://developer.matomo.org/guides/security-in-piwik#checklist)
* [ ] [Wording review done](https://developer.matomo.org/guides/pull-request-reviews#translations-wording-review-done)
* [ ] [Code review done](https://developer.matomo.org/guides/pull-request-reviews#code-review-done)
* [ ] [Tests were added if useful/possible](https://developer.matomo.org/guides/pull-request-reviews#tests-were-added-if-usefulpossible)
* [ ] [Reviewed for breaking changes](https://developer.matomo.org/guides/pull-request-reviews#reviewed-for-breaking-changes)
* [ ] [Developer changelog updated if needed](https://developer.matomo.org/guides/pull-request-reviews#developer-changelog-updated-if-needed)
* [ ] [Documentation added if needed](https://developer.matomo.org/guides/pull-request-reviews#documentation-added-if-needed)
* [ ] Existing documentation updated if needed
fatica
October 1, 2021, 7:37pm
6
This isnāt the same (AFAIK) as the consent cookie,
Notice our error is
there was an error setting cookie _pk_ref.2.1176
.
This is a newer issue in Chrome et.al to allow 3rd party cookies. You can see the error come back if you go into incognito mode.
Ref:
Lukas
(Lukas Winkler)
October 1, 2021, 7:41pm
7
Hi,
My point is that the whole There was an error setting cookie
message isnāt a new bug, but instead a new check that was added in https://github.com/matomo-org/matomo/pull/17744 (4.4.0) to see if any cookie that was created was actually existing. And if not, print this warning so issues can be easier debugged. But the logic was wrong and so the warning is now also shown in cases where everything is working fine (more precisely whenever a non-string is written to a cookie).
So it should not matter for this warning which cookie is written.
Unless of course this still occurs after applying https://github.com/matomo-org/matomo/pull/17928 which means that there might actually be an issue with writing the cookie.