Skip to content

Share Localization cookies with other application #13941

Discussion options

You must be logged in to vote

hi

You can change the domain of cookies.

Consts.SharedCookieDomain can be .example.com

public static IServiceCollection ConfigureShareCultureCookies(this IServiceCollection services)
{
	services.Configure<CookiePolicyOptions>(options =>
	{

		options.OnAppendCookie = cookieContext =>
		{
			SetCultureCookieDomain(cookieContext, null);
		};

		options.OnDeleteCookie = cookieContext =>
		{
			SetCultureCookieDomain(null, cookieContext);
		};
	});

	return services;
}

private static void SetCultureCookieDomain(AppendCookieContext appendCookieContext, DeleteCookieContext deleteCookieContext)
{
	if (appendCookieContext != null)
	{
		if (appendCookieContext.CookieName == CookieRequestCulturePr…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by abdullahshaqaliah
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants