Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
How to check the logged in users session and if they are logged in authenticated?

I have a identity validation problem I have a HTML and CSS I like to display for people logged in with a ticket number but whenever I start the application after I've closed it as a user logged in I always return as a logged in user with invalid ticket number.

<ul class="navbar-nav justify-content-end">
                        @if (HttpContext.Current.User.Identity.IsAuthenticated)
                        {
                            <li class="nav-item pt-4">
                                <a class="nav-link" aria-current="page" href="/mina-sidor/">Mina sidor</a>
                            </li>
                            <li class="nav-item pt-4">
                                @Html.ActionLink("Logga ut", "Logout", "Authentication", new { area = "" }, new { @class = "btn btn-primary" })
                            </li>
                            <li class="nav-item pt-4 px-1">
                                <p>Inloggad som <br /> <strong>@User.Identity.Name</strong></p>
                            </li>
                        }
                        else
                        {
                            <li class="nav-item pt-2">
                                @Html.ActionLink("Logga in", "Login", "Authentication", new { area = "" }, new { @class = "btn btn-primary" })
                            </li>
                        }

                    </ul>

HttpContext.Current.User.Identity.IsAuthenticated -> returns true always unless I manually log out.

I've tried Request.IsAuthenticated -> same here.

How do I handle that this return false when the website is closed or it has timed-out?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Have you a github or other repo to see your code?

Is the User.Identity.Name filled?

If your authentication system is based on cookie, exiting from the application the cookies aren't deleted/removed. So you need to verify if there are still there.

By default ASP.NET is configured for Session cookies. These cookies are not persistent and don't survive if you close your browser.

But if you have a persistent cookie with an expire time, like:

   theCookie.Expires = DateTime.Now.AddHours(1);

your session will survive to browser closing action.

If your authentication system is based on Session storage or Persistent storage check it via F12 - Application - Storage data.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!