From dea12085d9a63cf018542356ce6b7b5b8688f20b Mon Sep 17 00:00:00 2001 From: libexi01 Date: Fri, 19 Jul 2024 03:42:05 +0530 Subject: [PATCH] 30 --- s1/src/routes/faculty/login/+page.server.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/s1/src/routes/faculty/login/+page.server.ts b/s1/src/routes/faculty/login/+page.server.ts index 0b858af..a001423 100644 --- a/s1/src/routes/faculty/login/+page.server.ts +++ b/s1/src/routes/faculty/login/+page.server.ts @@ -1,5 +1,12 @@ import type { Actions } from "@sveltejs/kit"; import { redirect } from '@sveltejs/kit'; +import { browser } from '$app/environment'; + +function sessionStore(field: string, value: string) { + if (browser) { + window.sessionStorage.setItem(field, value); + } +} export const actions: Actions = { default: async ({ request }) => { @@ -17,11 +24,15 @@ export const actions: Actions = { }) console.log(res); var data1 = await res.json(); - console.log(data1); if (res.ok) { // Successful fetch - throw redirect(303, '/'); // Redirect to success page + sessionStore('firstName', data1.firstName); + sessionStore('lastName', data1.lastName); + sessionStore('email', data1.email); + sessionStore('password', data1.password); + // console.log(window.sessionStorage.getItem('firstName')); + throw redirect(303, '/faculty'); // Redirect to success page } else { // Handle error return {