Click here to Skip to main content
15,887,430 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
need to set the secure flag for session cookies.

I have tried like below but session will null, displays Session Expired. Please login again.
<httpCookies   requireSSL="true" />

i'm setting secure flag for cookie as like above code in <system.web>

cs page code:
protected void Page_Load(object sender, EventArgs e)
   {
       if (Request.ServerVariables["HTTP_REFERER"] != null)
       {
           if (Request.Form["mwa"] != null && Request.Form["mwp"] != null)
           {
               String EmployeeNo = Request.Form["mwa"];
               String ApplicationID = Request.Form["mwp"];
               TripleDESSecureAlgorithm.CipherCode objTripleDes = new TripleDESSecureAlgorithm.CipherCode();
               String strEmpNumbDec = objTripleDes.Decrypt(EmployeeNo, ApplicationID);
               if (strEmpNumbDec != "")
               {
                   Session["EMPID"] = strEmpNumbDec;
               }
           }
           if (HttpContext.Current.Session["EMPID"] == null)
           {
               Response.Write("<center>Session Expired. Please login again.</center>");
               Response.End();
           }


and
<authentication mode="Forms">
    <forms loginUrl="~/Account/Login.aspx" timeout="2880"  />
  </authentication>
in <system.web>

Please help me in this case why current session is null.? or any other way to implement this ?

What I have tried:

I have tried like below but session will null, displays Session Expired. Please login again.
<httpCookies   requireSSL="true" />
Posted
Updated 14-Oct-18 23:52pm
v2
Comments
F-ES Sitecore 15-Oct-18 6:45am    
Let's start with some basics...are you accessing the site over https?
#realJSOP 15-Oct-18 15:29pm    
Tell him to read the documentation. I dare ya...
Virendra S from Bangalore, Karnataka 18-Oct-18 1:57am    
Yeah, accessing it over https..
Virendra S from Bangalore, Karnataka 18-Oct-18 2:03am    
I have tried this also <httpCookies httpOnlyCookies="true" requireSSL="true" />
but no use same, session is null, hence displaying Session Expired. Please login again.

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