Click here to Skip to main content
15,921,156 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to override the cookie path for ASP.NET using asp.net with c#. I tried setting the cookie with path pointing to the Virtual Application Directory.
I am able to point to the desired directory configured in config file but multiple cookies are getting generated

What I have tried:

Web.Config file
    <add key="UserDefiniedCookiePathFilter" value="/DDS_AHB"/>

Global.asax page
Under Application_PreSendRequestHeaders Event

string CookiePath= ConfigurationManager.AppSettings["UserDefiniedCookiePathFilter"];
            Response.AppendHeader("Set-Cookie", "path="+CookiePath);
Posted
Updated 6-Jan-20 3:50am

1 solution

If your web site has EnableSessionState=false, or of the cookie doesn't have an expiration date/time, it won't save a cookie. Beyond that, I don't know why it wouldn't work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900