Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 988711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:40:37+00:00 2026-05-16T05:40:37+00:00

I have a login problem. First i am using SSL while logging. When i

  • 0

I have a login problem.

First i am using SSL while logging.

When i log in, i am creating a cookie like this. when i check if it is secure the answer is yes.

FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1,                          // version
                                                   UserName.Text,           // user name
                                                   DateTime.Now,               // creation
                                                   DateTime.Now.AddMinutes(60),// Expiration
                                                   false,                      // Persistent 
                                                   role);         // User data

                    // Now encrypt the ticket.
                    string encryptedTicket = FormsAuthentication.Encrypt(authTicket);

                    // Create a cookie and add the encrypted ticket to the
                    // cookie as data.
                    HttpCookie authCookie =
                                 new HttpCookie(FormsAuthentication.FormsCookieName,
                                                encryptedTicket);

                    if (authCookie.Secure)
                    {
                        new GUIUtility().LogMessageToFile("The cookie is secure with SSL.");
                        // Add other required code here.
                    }

                    authCookie.Secure = FormsAuthentication.RequireSSL;

                    // Add the cookie to the outgoing cookies collection.
                    HttpContext.Current.Response.Cookies.Add(authCookie);

                    // Redirect the user to the originally requested page 
                    Response.Redirect(FormsAuthentication.GetRedirectUrl(UserName.Text,false));

then this is redirected to the global.asax page which has this code:

string cookieName = FormsAuthentication.FormsCookieName.ToString();
        HttpCookie authCookie = Context.Request.Cookies[cookieName];

        try
        {
            new GUIUtility().LogMessageToFile(cookieName + authCookie.Secure);
        }
        catch (Exception)
        {
            //
        }

here i get the cookieName as “.ASPXAUTH” and authCookie.Secure value as False.
Why is this happening i want the authCookie.Secure value to be true here.

Any suggestions?? thanks

my web config has this:

<authentication mode="Forms">
        <forms loginUrl="Login.aspx" defaultUrl="~/Default.aspx" slidingExpiration="true" timeout="120" path="/" requireSSL="true" protection="All">
        </forms>
    </authentication>
<httpCookies requireSSL="true"/>
    <authorization>
        <deny users="?"/>
        <!--<allow users="*"/>-->
    </authorization>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:40:38+00:00Added an answer on May 16, 2026 at 5:40 am

    Restrict the Authentication Cookie-to-HTTPS Connections

    Cookies support a “secure” property that determines whether or not browsers should send the cookie back to the server. With the secure property set, the cookie is sent by the browser only to a secure page that is requested using an HTTPS URL.

    If you are using .NET Framework version 1.1, set the secure property by using requireSSL=”true” on the element as follows:

    <forms loginUrl="Secure\Login.aspx"
       requireSSL="true" . . . />
    

    If you are using .NET Framework version 1.0, set the secure property manually in the Application_EndRequest event handler in Global.asax using the following code:

    protected void Application_EndRequest(Object sender, EventArgs e) 
     {
    string authCookie = FormsAuthentication.FormsCookieName;
    
    foreach (string sCookie in Response.Cookies) 
     {
    if (sCookie.Equals(authCookie))
    { 
      // Set the cookie to be secure. Browsers will send the cookie
      // only to pages requested with https
      Response.Cookies[sCookie].Secure = true;
    }
    

    }
    }

    so according to me the first option is not working in web config so im doing it manually
    which is the second option in the code..

    Please suggest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 499k
  • Answers 499k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You often don't need to. For example, you can just… May 16, 2026 at 12:40 pm
  • Editorial Team
    Editorial Team added an answer Take a look at the Scheduled Task. On the task… May 16, 2026 at 12:40 pm
  • Editorial Team
    Editorial Team added an answer Have you tried using a DateTime in the VB.NET code… May 16, 2026 at 12:40 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have this problem. I first connect(log) to SQL Server using SQL Management Studio
I am using ASP.NET MVC2 and have a problem. After Log off I manually
I've completed my login page. My problem now is I can only log in
I have a mobile application that I'm using with Facebook connect. I'm having trouble
I am designing a web application using GWT currently, which is also the first
We have build a intranet application where users have to login to do certain
I have a masterpage and inside that masterpage I have to check if a
I have a problem that I had working in a test but now in
I have a problem with a site I am redesigning and the problem is
I have an Acl plug-in which extends Zend_Controller_Plugin_Abstract , this plug-in handles all my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.