Ich versuche gerade vergeblich parallel zum Shop einen Blog durch den gleichen Cookie Consent zu schützen, den der shop nutzt.
Ich habe versucht den ganzen benötigten Javascript im Blog einzubinden:
<script id
="oil-configuration" type
="application/configuration"> { "config_version": 1, "preview_mode": false, "advanced_settings": true, "timeout": 0, "iabVendorListUrl": "https://www.domain.de/ajax.php?ext=get_cookie_consent&speed=1&language=de", "locale": { "localeId": "de", "version": 1, "texts": { "label_intro_heading": "Diese Webseite verwendet Cookies und andere Technologien", "label_intro": "Wir verwenden Cookies und ähnliche Technologien, auch von Drittanbietern, um die ordentliche Funktionsweise der Website zu gewährleisten, die Nutzung unseres Angebotes zu analysieren und Ihnen ein bestmögliches Einkaufserlebnis bieten zu können. Weitere Informationen finden Sie in unserer Datenschutzerklärung.", "label_button_yes": "Speichern", "label_button_back": "Zurück", "label_button_yes_all": "Alle Akzeptieren", "label_button_advanced_settings": "Weitere Informationen", "label_cpc_heading": "Cookie Einstellungen", "label_cpc_activate_all": "Alle aktivieren", "label_cpc_deactivate_all": "Alle deaktivieren", "label_nocookie_head": "Keine Cookies erlaubt.", "label_nocookie_text": "Bitte aktivieren Sie Cookies in den Einstellungen Ihres Browsers.", "label_third_party": " ", "label_imprint_links": "<a href='https://www.domain.de/popup_content.php?coID=2' onclick='return cc_popup_content(this)'>Datenschutzerklärung</a> <a href='https://www.domain.de/popup_content.php?coID=4' onclick='return cc_popup_content(this)'>Impressum</a>" } }}</script> <script src
="/templates/mytemplate/javascript/oil.min.js"></script> <script
>!function(e
){var n
={};function t
(o
){if(n
[o
])return n
[o
].exports
;var r
=n
[o
]={i
:o
,l
:!1,exports
:{}};return e
[o
].call
(r
.exports
,r
,r
.exports
,t
),r
.l
=!0,r
.exports
}t
.m
=e
,t
.c
=n
,t
.d
=function(e
,n
,o
){t
.o
(e
,n
)||Object
.defineProperty
(e
,n
,{configurable
:!1,enumerable
:!0,get
:o
})},t
.r
=function(e
){Object
.defineProperty
(e
,"__esModule",{value
:!0})},t
.n
=function(e
){var n
=e
&&e
.__esModule?
function(){return e
.default}:function(){return e
};return t
.d
(n
,"a",n
),n
},t
.o
=function(e
,n
){return Object
.prototype
.hasOwnProperty
.call
(e
,n
)},t
.p
="/",t
(t
.s
=115)}({115:function(e
,n
,t
){"use strict";!function(e
,n
){e
.__cmp
||(e
.__cmp
=function(){function t
(e
){if(e
){var t
=!0,r
=n
.querySelector
('script[type="application/configuration"]#oil-configuration');if(null!==r
&&r
.text
)try
{var a
=JSON
.parse
(r
.text
);a
&&a
.hasOwnProperty
("gdpr_applies_globally")&&(t
=a
.gdpr_applies_globally
)}catch
(e
){}e
({gdprAppliesGlobally
:t
,cmpLoaded
:o
()},!0)}}function o
(){return!(!e
.AS_OIL
||!e
.AS_OIL
.commandCollectionExecutor
)}var r
=[],a
=function(n
,a
,c
){if("ping"===n
)t
(c
);else{var i
={command
:n
,parameter
:a
,callback
:c
};r
.push
(i
),o
()&&e
.AS_OIL
.commandCollectionExecutor
(i
)}};return a
.commandCollection
=r
,a
.receiveMessage
=function(n
){var a
=n
&&n
.data
&&n
.data
.__cmpCall
;if(a
)if("ping"===a
.command
)t
(function(e
,t
){var o
={__cmpReturn
:{returnValue
:e
,success
:t
,callId
:a
.callId
}};n
.source
.postMessage
(o
,n
.origin
)});else{var c
={callId
:a
.callId
,command
:a
.command
,parameter
:a
.parameter
,event
:n
};r
.push
(c
),o
()&&e
.AS_OIL
.commandCollectionExecutor
(c
)}},function(n
){(e
.attachEvent
||e
.addEventListener
)("message",function(e
){n
.receiveMessage
(e
)},!1)}(a
),function e
(){if(!(n
.getElementsByName
("__cmpLocator").length
>0))if(n
.body
){var t
=n
.createElement
("iframe");t
.style
.display
="none",t
.name
="__cmpLocator",n
.body
.appendChild
(t
)}else setTimeout
(e
,5)}(),a
}())}(window
,document
)}});</script><script
>function cc_popup_content
(trgt
) { $
.colorbox
({href
:trgt
.href
, iframe
:true, width
:"780", height
:"560", maxWidth
: "90%", maxHeight
: "90%", fixed
: true}); return false;}(function() { // Cross browser event handler definition let eventMethod
= window
.addEventListener ?
'addEventListener' : 'attachEvent'; let messageEvent
= eventMethod
=== 'attachEvent' ?
'onmessage' : 'message'; let eventer
= window
[eventMethod
]; // Callback to be executed when event is fired function receiveMessage
(event
) { let eventDataContains
= function(str
) { return JSON
.stringify
(event
.data
).indexOf
(str
) !== -1; }; let oilGtagCookie
= function(data
) { let cookieDate
= new Date; // the oil.js cookie expires after 1 month cookieDate
.setMonth
(cookieDate
.getMonth
() + 1); let cookieString
= 'MODOilTrack=' + JSON
.stringify
(data
.purposeConsents
) + ';'; cookieString
+= 'expires=' + cookieDate
.toUTCString
() + ';'; cookieString
+= 'path=/;SameSite=Lax;'; if (typeof SetSecCookie
!== 'undefined' && SetSecCookie
== true) { cookieString
+= 'Secure;'; } document
.cookie
= cookieString
; }; if (event
&& event
.data
&& (eventDataContains
('oil_optin_done') || eventDataContains
('oil_has_optedin'))) { __cmp
('getVendorConsents', [], oilGtagCookie
); } } // Register event handler eventer
(messageEvent
, receiveMessage
, false); $
(document
).on
('click', '[trigger-cookie-consent-panel]', function () { window
.AS_OIL
.showPreferenceCenter
(); if (!$
('.as-oil.light').length
) { $
('body').append
( $
('<div/>') .addClass
('as-oil light') .append
( $
('<div/>') .attr
('id', 'oil-preference-center') .addClass
('as-oil-content-overlay cpc-dynamic-panel') ) ); } });})();</script> Soweit klappt das erstmal schon im Ansatz. Die Probleme gehen aber dann los, wenn ich mich zuerst im Blog befinde und dann in den Shop gehe, dann kommt im Shop nochmals der Cookie Consent, obwohl ich zuvor schon zugestimmt hatte.
Ich hab dann herausgefunden, dass - wieso auch immer - der Pfad des Cookies "oil_data" im Blog nach Zustimmung nicht auf / sondern auf /blog/subdir gesetzt wird.
Ich hab keine Ahnung wieso das so ist. Die template/mytemplate/javascript/oil.min.js anzupassen kann ja eigentlich nicht der richtige Weg sein, oder?
Im o.g. Javascript sehe ich aber nicht wie ich das ändern könnte.
Ich hab auch schon versucht den Cookie dort einfach neu zu setzen, das funktioniert aber nicht, weil der oil_data cookie sich immer erst danach generiert und dann habe ich zwei Cookies mit identischem Namen.
Wäre klasse, wenn hier jemand einen Ansatz hat.
Linkback: https://www.modified-shop.org/forum/index.php?topic=41935.0