views:

31

answers:

1

I have two applications on my webserver.
myserver.com/ApplicationA
myserver.com/ApplicationB

Both applications are using similar codebases and so there are several overlaps in their cookie names, which are causing problems...

I'm aware that it is possible to limit a cookie in ASP.Net so that only applications on a certain "Path" can access it. However, what I'd really like to do this without having to make any code changes to either application.

Is it possible to configuare an ASP.Net application to default to limiting ALL of its cookies to a certain path?

Thanks,
Neil

+1  A: 

Sadly the web.configuration httpCookies element only allows you to set the default domain, and not the path.

You'd need to set the Path property as you write the cookie, which means that you will need to make some code changes - your best bet would probably be to factor out cookie writing to a shared class, and then use either a value from the web.config or get the application root path to set the property correctly.

Zhaph - Ben Duguid
Thanks Ben, that's great.Long term, I think I'll go with your refactoring suggestion, but for the short term, I'm planning to put the applications on different domains.If I understand your post correctly, this ought to work, is that correct?appA.myserver.comappB.myserver.comThanks again,Neil
NeilD
PS... New to stackoverflow, so apologies for formatting mayhem above.
NeilD
Yes, moving to sub domains should work - be aware that any cookies set to `.myserver.com` would be visible to both applications.
Zhaph - Ben Duguid