HI, @tsm012. How did you solve the above issue? I am experiencing the same issue.
utils/cookies.js
import {withIronSession} from 'next-iron-session'; const cookie = { cookieName: process.env.COOKIE_NAME, password: process.env.COOKIE_SECRET, cookieOptions: {secure: process.env.NODE_ENV === 'production'}, }; export const guard = (handler) => { return withIronSession(handler, cookie); }; export default cookie;
.... req.session.set('user', { user }); // persist session value await req.session.save(); console.log(req.session.get('user')); return res.status(201).json({success, message});
export const getServerSideProps = guard(async (ctx) => { const {req} = ctx; const session = req.session.get(); console.log({session}); return {redirect: {destination: '/sign-in', permanent: false}}; });
At this point, the session is empty e.g { }
{ }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
HI, @tsm012. How did you solve the above issue? I am experiencing the same issue.
Create a util in
utils/cookies.js
Implement lookup logic
Attempt to access the session value
At this point, the session is empty e.g
{ }