diana sotirova
03/19/2026, 4:25 PMDevRev
03/19/2026, 4:26 PM<AuthProvider
projectId="your-project-id"
sessionTokenViaCookie={{
sameSite: 'None',
secure: true,
cookieName: 'sessionToken'
}}
baseUrl="https://auth.app.example.com"
>
<App />
</AuthProvider>
Available Cookie Options
• `cookieName`: Custom session token cookie name (default: DS)
• `sameSite`: Cookie same-site policy (Strict, Lax, None)
• `secure`: HTTPS-only cookie flag
For additional custom cookie logic beyond authentication tokens, you can use Scriptlets within your flow for custom JavaScript data manipulation .
Descope Component Guide | Client SDK | Descope Documentation
Flows Overview | Descope Documentationdiana sotirova
03/19/2026, 4:27 PMDevRev
03/19/2026, 4:27 PMSet-Cookie header
4. Enable "Include response headers in Context" to access headers in flow context
// Your backend endpoint response
{
"Set-Cookie": "customCookie=customValue; Path=/; HttpOnly"
}
Client-Side Approach
Handle cookie setting in your application after flow completion:
// In your flow success handler
onSuccess: (result) => {
document.cookie = "customCookie=customValue; path=/";
// Continue with your app logic
}
Scriptlet Limitations
While Scriptlets allow custom JavaScript within flows , they run server-side and cannot directly set browser cookies. They're useful for data manipulation but not cookie operations .
The HTTP connector approach is recommended if you need server-controlled cookie setting during the authentication flow.
Connectors in Flows | Descope Documentation
Generic HTTP Connector | Descope Documentation
Flows Overview | Descope Documentation
Flows Overview | Descope Documentationdiana sotirova
03/19/2026, 4:32 PMDevRev
03/19/2026, 4:32 PM{
"customHeader": "My header value",
"Set-Cookie": "customCookie=value; Path=/",
...
}
Use Cases
• Extract custom headers from API responses
• Use header values in Custom Claims actions
• Add header data to JWT tokens
This setting must be configured at the connector level, not in the individual flow step. The headers will then be accessible in subsequent flow actions and conditions.
Generic HTTP Connector | Descope Documentationdiana sotirova
03/19/2026, 4:47 PMDevRev
03/19/2026, 4:47 PMSet-Cookie header in the connector response only affects the Descope-to-backend request
• Browser cookies require a direct browser-to-server response
Solutions
Option 1: Return Cookie Data to Client
Use the End action to return cookie data, then set it client-side:
// In End action outputs
{
"cookieName": "disableLegacyLogin",
"cookieValue": "true"
}
// In your client success handler
onSuccess: (result) => {
if (result.cookieName && result.cookieValue) {
document.cookie = `${result.cookieName}=${result.cookieValue}; path=/`;
}
}
Option 2: Backend Redirect Approach
Have your backend return a redirect URL that sets the cookie:
1. Backend responds with redirect URL containing cookie-setting endpoint
2. Use the redirect URL in your flow's End action
3. Browser follows redirect and receives the Set-Cookie header
The key point: only direct browser-to-server responses can set browser cookies, not server-to-server connector responses.diana sotirova
03/19/2026, 4:49 PMDevRev
03/19/2026, 4:49 PM<Descope
projectId="your-project-id"
flowId="your-flow-id"
onSuccess={(e) => {
console.log('Flow completed:', e.detail);
// Set cookie from flow response
if (e.detail.cookieName && e.detail.cookieValue) {
document.cookie = `${e.detail.cookieName}=${e.detail.cookieValue}; path=/`;
}
}}
onError={(e) => console.error('Flow error:', e.detail)}
/>
Vue.js
<descope-wc
project-id="your-project-id"
flow-id="your-flow-id"
@success="handleSuccess"
@error="handleError"
/>
<script>
export default {
methods: {
handleSuccess(e) {
console.log('Flow completed:', e.detail);
if (e.detail.cookieName && e.detail.cookieValue) {
document.cookie = `${e.detail.cookieName}=${e.detail.cookieValue}; path=/`;
}
}
}
}
</script>
Web Components/HTML
const descopeWc = document.querySelector('descope-wc');
descopeWc.addEventListener('success', (e) => {
console.log('Flow completed:', e.detail);
if (e.detail.cookieName && e.detail.cookieValue) {
document.cookie = `${e.detail.cookieName}=${e.detail.cookieValue}; path=/`;
}
});
The e.detail object contains the flow response data, including any outputs you configured in your End action.diana sotirova
03/19/2026, 4:58 PMDevRev
03/19/2026, 4:58 PMSet-Cookie headers to the flow response. Scriptlets run server-side JavaScript for data manipulation but don't control HTTP response headers .
Why This Limitation Exists
• Scriptlets process data within the flow context
• They return JavaScript objects, not HTTP responses
• Response headers are controlled by Descope's flow engine, not custom code
Alternative Approaches
Option 1: Use End Action Outputs
Return cookie data from your scriptlet, then handle it client-side:
// In scriptlet
return {
cookieName: "disableLegacyLogin",
cookieValue: "true",
cookiePath: "/"
};
Option 2: HTTP Connector + Client Handler
Your current approach is correct - use the HTTP connector response data in the client success handler to set the cookie via JavaScript.
Option 3: Backend Redirect
Have your backend API return a redirect URL that includes cookie-setting logic, then use that URL in your End action.
The key limitation: only direct browser-to-server responses can set browser cookies, not server-side scriptlet execution.
Scriptlets | Descope Documentation