Click here to Skip to main content
16,017,852 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am making cookies attribute secure and application logout Please give the solution not to log out
Below is the code which I am using in global.asax

protected void Application_EndRequest(Object sender, EventArgs e)
       {
           // Iterate through any cookies found in the Response object.
           foreach (string cookieName in Response.Cookies.AllKeys)
           {
               Response.Cookies[cookieName].Secure = true;
               Response.Cookies[cookieName].Path = ConfigurationManager.AppSettings["UserDefiniedCookiePathFilter"];
           }
       }


What I have tried:

protected void Application_EndRequest(Object sender, EventArgs e)
       {
           // Iterate through any cookies found in the Response object.
           foreach (string cookieName in Response.Cookies.AllKeys)
           {
               Response.Cookies[cookieName].Secure = true;
               Response.Cookies[cookieName].Path = ConfigurationManager.AppSettings["UserDefiniedCookiePathFilter"];
           }
       }
Posted
Updated 19-Dec-22 1:35am

1 solution

Your site needs to be served over HTTPS, and the application path needs to match the case-sensitive path specified by the "UserDefiniedCookiePathFilter" setting from your web.config file.

(See: https://stackoverflow.com/questions/399982/why-are-cookie-paths-case-sensitive[^])

Beyond that, we can't tell you what the problem is - we have no access to your server or your site. You will need to debug your code to find out why the cookies aren't being sent.

Start by checking your browser's developer console for errors or warnings. Most of them have a "storage" section to show you the cookies that have been sent back from the server.
 
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