Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization Cookie Static Conditional HttpOnly=True #4730

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Oqtane.Client/Themes/Controls/Theme/LanguageSwitcher.razor
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
Expires = DateTimeOffset.UtcNow.AddYears(365),
SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Lax, // Set SameSite attribute
Secure = true, // Ensure the cookie is only sent over HTTPS
HttpOnly = false // cookie is updated using JS Interop in Interactive render mode
HttpOnly = PageState.RenderMode == RenderModes.Static // Sets the cookie with HttpOnly=true only if the render mode is Static.
// In Interactive mode, cookies are updated using JavaScript Interop,
// which requires HttpOnly to be false.
});

}
Expand Down
4 changes: 3 additions & 1 deletion Oqtane.Server/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,9 @@
Expires = DateTimeOffset.UtcNow.AddYears(1),
SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Lax, // Set SameSite attribute
Secure = true, // Ensure the cookie is only sent over HTTPS
HttpOnly = false // cookie is updated using JS Interop in Interactive render mode
HttpOnly = _renderMode == RenderModes.Static // Sets the cookie with HttpOnly=true only if the render mode is Static.
// In Interactive mode, cookies are updated using JavaScript Interop,
// which requires HttpOnly to be false.
};

Context.Response.Cookies.Append(
Expand Down