Skip to content

Commit

Permalink
added changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
kaytwo committed Dec 30, 2024
1 parent b06af08 commit 826c88f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .changeset/hot-baboons-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

ensure session regeneration
10 changes: 9 additions & 1 deletion examples/basics/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
// @ts-check
import { defineConfig } from 'astro/config';

import node from '@astrojs/node';

// https://astro.build/config
export default defineConfig({});
export default defineConfig({
experimental: { session: { driver: 'fs' } },

adapter: node({
mode: 'standalone',
}),
});
7 changes: 5 additions & 2 deletions examples/basics/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
---
import Welcome from '../components/Welcome.astro';
import Layout from '../layouts/Layout.astro';
export const prerender = false;
// Welcome to Astro! Wondering what to do next? Check out the Astro documentation at https://docs.astro.build
// Don't want to use any of this? Delete everything in this file, the `assets`, `components`, and `layouts` directories, and start fresh.
await Astro.session.regenerate();
const sessionId = `the current session ID is: ${Astro.cookies.get('astro-session')?.value}`;
---

<Layout>
<Welcome />
This page refreshes its session ID on every load. It is currently {sessionId}
</Layout>
1 change: 1 addition & 0 deletions examples/ssr/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import node from '@astrojs/node';

// https://astro.build/config
export default defineConfig({
experimental: { session: { driver: 'fs' } },
output: 'server',
adapter: node({
mode: 'standalone',
Expand Down
35 changes: 6 additions & 29 deletions examples/ssr/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
---
import Header from '../components/Header.astro';
import Container from '../components/Container.astro';
import ProductListing from '../components/ProductListing.astro';
import { getProducts } from '../api';
import '../styles/common.css';
export const prerender = false;
// Welcome to Astro! Wondering what to do next? Check out the Astro documentation at https://docs.astro.build
// Don't want to use any of this? Delete everything in this file, the `assets`, `components`, and `layouts` directories, and start fresh.
const products = await getProducts(Astro.request);
await Astro.session.regenerate();
const sessionId = `the current session ID is: ${Astro.cookies.get('astro-session')?.value}`;
---

<html lang="en">
<head>
<title>Online Store</title>
<style>
h1 {
font-size: 36px;
}

.product-listing-title {
text-align: center;
}
</style>
</head>
<body>
<Header />

<Container tag="main">
<ProductListing products={products}>
<h2 class="product-listing-title" slot="title">Product Listing</h2>
</ProductListing>
</Container>
</body>
</html>
This page refreshes its session ID on every load. It is currently {sessionId}

0 comments on commit 826c88f

Please sign in to comment.