Skip to content

Commit

Permalink
Merge pull request #81 from multinet-app/cookie-set-on-TLD
Browse files Browse the repository at this point in the history
Get last 2 piece of url (split by .) for the cookie domain
  • Loading branch information
JackWilb authored Mar 14, 2023
2 parents b21cfd5 + ac6ad5c commit 10dbc24
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export function multinetApi(baseURL: string): MultinetAPI {

export function writeSharedLoginCookie(token: string, domain?: string) {
if (domain === undefined) {
domain = window.location.hostname;
domain = window.location.hostname.split('.').slice(-2).join('.');
}
document.cookie = `sharedLogin=${token}; Domain=${domain}`;
}
Expand All @@ -295,7 +295,7 @@ export function readSharedLoginCookie(): string | null {

export function invalidateSharedLoginCookie(domain?: string) {
if (domain === undefined) {
domain = window.location.hostname;
domain = window.location.hostname.split('.').slice(-2).join('.');
}
document.cookie = `sharedLogin=; Domain=${domain}; Max-Age=0`;
}

0 comments on commit 10dbc24

Please sign in to comment.