We are using ServiceStack, and want to host the same service on multiple custom domains (e.g. exampe.com, example2.com.
We cannot rely on the default handling in service stack as that will drop a cookie at the request level e.g. "auth.example.com" whereas we need a cookie for the whole domain, so have been overriding this behaviour by setting RestrictAllCookiesToDomain="example.com" when the application starts up.
Now we need to host the same service on multiple domains, and need drop a different cookie based on the host. For example if the host is auth.example2.com, we want to drop a cookie on "example2.com" (without the subdomain).
I have found the CookieOptionsFilter in servicestack, but this gives me no access to the request/hostname - so I am a little stuck.
Am I going about this the wrong way, or am I missing something here?
Thankyou!
Inside AppHost.SetCookieFilter(IRequest,Cookie) you have access to the IRequest and can set the Domain there, e.g:
public override bool SetCookieFilter(IRequest req, Cookie cookie)
{
cookie.Domain = "...";
return base.SetCookieFilter(req, cookie.Name);
}
If you want to control it per request don't set RestrictAllCookiesToDomain otherwise it will override the domain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With