Skip to content

Commit 9c2d68a

Browse files
authored
Merge pull request #26 from ivanhrytsaim/10660-Back-Login-Redirect-Issue_v2
10660-Back-Login-Redirect-Issue
2 parents 19f01d9 + a978113 commit 9c2d68a

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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.getCookie = function(cookieName) {
15+
let name = cookieName + '=';
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>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.setCookie = function(name, value, params) {
15+
if (!name) {
16+
return;
17+
}
18+
19+
params = params || {};
20+
21+
var expires = params.expires;
22+
var path = params.path || '/';
23+
var domain = params.domain || window.location.hostname;
24+
25+
var cookieString = encodeURIComponent(name) + '=' + encodeURIComponent(value);
26+
27+
if (expires instanceof Date) {
28+
cookieString += '; expires=' + expires.toUTCString();
29+
}
30+
cookieString += '; path=' + path;
31+
cookieString += '; domain=' + domain;
32+
document.cookie = cookieString;
33+
};
34+
35+
</script>

0 commit comments

Comments
 (0)