-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (31 loc) · 915 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import repoLink from "../../components/repo-link.js";
export default {
title: "Setting cookies",
metaDescription: "Set HTTP cookie values",
page: function () {
return `
<section>
<h1>Setting cookies</h1>
<p>Use an Edge Function to create and manage HTTP cookies.</p>
<pre><code>import type { Context } from "https://edge.netlify.com";
export default async (request: Request, context: Context) => {
// Set a cookie
context.cookies.set({
name: "My cookie",
value: "hello",
});
};</code></pre>
<h2>See this in action</h2>
<ul>
<li><a href="/cookies?action=set">Set a cookie</a></li>
<li>${repoLink("cookies.ts")}</li>
</ul>
<h2>Related</h2>
<ul>
<li><a href="/example/cookies-read">Read the value of a cookie</a></li>
<li><a href="/example/cookies-delete">Delete a cookie</a></li>
</ul>
</section>
`;
},
};