File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 11import { SessionStore } from "./types" ;
22
33export interface CookieSessionStoreOptions {
4+ domain ?: string ;
45 path ?: string ;
56 sameSite ?: "Lax" | "Strict" | "None" ;
67 useExplicitExpiry ?: boolean ;
@@ -12,14 +13,14 @@ export default class CookieSessionStore implements SessionStore {
1213 private readonly path : string ;
1314 private readonly sameSite : string ;
1415 private readonly useExplicitExpiry : boolean ;
16+ private readonly domain : string ;
1517
1618 constructor ( cookieName : string , opts : CookieSessionStoreOptions = { } ) {
1719 this . sessionName = cookieName ;
18-
1920 this . path = ! ! opts . path ? `; path=${ opts . path } ` : "" ;
21+ this . domain = ! ! opts . domain ? `; domain=${ opts . domain } ` : "" ;
2022 this . sameSite = ! ! opts . sameSite ? `; SameSite=${ opts . sameSite } ` : "" ;
2123 this . useExplicitExpiry = ! ! opts . useExplicitExpiry ;
22-
2324 if ( typeof window !== "undefined" ) {
2425 this . secureFlag = window . location . protocol === "https:" ? "; secure" : "" ;
2526 }
@@ -44,7 +45,7 @@ export default class CookieSessionStore implements SessionStore {
4445 expiresDate . setTime ( exp ) ;
4546 expires = `; expires=${ expiresDate . toUTCString ( ) } ` ;
4647 }
47- document . cookie = `${ this . sessionName } =${ val } ${ this . secureFlag } ${ expires } ${ this . path } ${ this . sameSite } ` ;
48+ document . cookie = `${ this . sessionName } =${ val } ${ this . secureFlag } ${ expires } ${ this . path } ${ this . sameSite } ${ this . domain } ` ;
4849 }
4950 }
5051
You can’t perform that action at this time.
0 commit comments