Skip to main content
InterviewHubPRO
Section Overview
Q22

Question 22 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

44%
Astro Islands & SSR (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

Server-Side Session and Cookie Management in Astro SSR.

senior LevelCode ExampleSSR & HydrationSystem DesignAstro

In Simple Words: In SSR mode, read and write HTTP-only cookies securely:

astro
---
// Read cookie
const sessionId = Astro.cookies.get('session_id')?.value;

// Set cookie on form action
if (Astro.request.method === 'POST') {
  Astro.cookies.set('session_id', newSession, {
    httpOnly: true,
    secure: true,
    sameSite: 'strict',
    path: '/'
  });
}
---