Is there a way to specify the port for a HttpCookie?

I have a site that is available at sub.example.com and needs to be deployed at sub.example.com:81 and sub.example.com:82.(so the same domain, different ports -- using Apache2 and mono)

The authentication is done by using cookies specifying the domain and path:

sub.example.com (domain = "sub.example.com" path = "/")
sub.example.com:81 (domain = "sub.example.com:81" path = "/") 
sub.example.com:82 (domain = "sub.example.com:82" path = "/")
// seems that the port in domain is not used... 

All works fine for sub.example.com, but when logged on sub.example.com, the page at sub.example.com:81 also receives the 'authentication' cookie set by sub.example.com.

So I want to be able to specify also the port to a httpCookie, to restricts the ports to which this Cookie may be sent. Or maybe there is a workaround to simulate this...

有帮助吗?

解决方案

When creating the cookie, you can set the Port-property of the Cookie to the correct port.

More info can be found at: http://msdn.microsoft.com/en-us/library/system.net.cookie.port%28VS.80%29.aspx

其他提示

Just for clarity - no, it's not possible when using HttpCookie.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top