File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed
Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright © Magefan ([email protected] ). All rights reserved. 4+ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
5+ */
6+ ?>
7+ <?php
8+ /**
9+ * @var $block \Magefan\Community\Block\JsScript
10+ */
11+ ?>
12+ <script data-mfmofile="true">
13+ window.MagefanJs = window.MagefanJs || {};
14+ window.MagefanJs.getCookies = function getCookies(options) {
15+ let name = options + "=";
16+ let decodedCookie = decodeURIComponent(document.cookie);
17+ let ca = decodedCookie.split(';');
18+ for(let i = 0; i <ca.length; i++) {
19+ let c = ca[i];
20+ while (c.charAt(0) == ' ') {
21+ c = c.substring(1);
22+ }
23+ if (c.indexOf(name) == 0) {
24+ return c.substring(name.length, c.length);
25+ }
26+ }
27+ return "";
28+ }
29+ </script>
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright © Magefan ([email protected] ). All rights reserved. 4+ * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
5+ */
6+ ?>
7+ <?php
8+ /**
9+ * @var $block \Magefan\Community\Block\JsScript
10+ */
11+ ?>
12+ <script data-mfmofile="true">
13+ window.MagefanJs = window.MagefanJs || {};
14+ window.MagefanJs.setCookies = function setCookies(options) {
15+ options = options || {};
16+ if (!options.name || !options.value) {
17+ return;
18+ }
19+ var expires = options.expires;
20+ var path = options.path || '/';
21+ var domain = options.domain || window.location.hostname;
22+
23+ var cookieString = encodeURIComponent(options.name) + '=' + encodeURIComponent(options.value);
24+
25+ if (expires instanceof Date) {
26+ cookieString += '; expires=' + expires.toUTCString();
27+ }
28+ cookieString += '; path=' + path;
29+ cookieString += '; domain=' + domain;
30+ document.cookie = cookieString;
31+ };
32+
33+ </script>
You can’t perform that action at this time.
0 commit comments