1/** 2 * Session cookie handling, mirrors the Nuxt frontends (middleware/auth.global.ts). 3 * 4 * The cookie value is base64(JSON) of { id, iat, exp } and is used by the API as 5 * the session id. The API rejects a null session, so create one when missing. 6 * 7 * Requires thirdparty/js.cookie.js. 8 */ 9 10var SESSION_COOKIE_NAME = "session"; 11 12function getSession() { 13 return Cookies.get(SESSION_COOKIE_NAME) || createSession(); 14} 15 16function createSession() { 17 var expirationDate = getDateOneYearFromNow(); 18 19 var session = btoa( 20 JSON.stringify({ 21 id: 0, // Guest 22 iat: new Date().getTime(), 23 exp: expirationDate.getTime(), 24 }) 25 ); 26 27 Cookies.set(SESSION_COOKIE_NAME, session, { expires: expirationDate, path: "/" }); 28 29 return session; 30} 31 32function getDateOneYearFromNow() { 33 var oneYearFromNow = new Date(); 34 oneYearFromNow.setFullYear(oneYearFromNow.getFullYear() + 1); 35 36 return oneYearFromNow; 37}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.