---
title: "How to check whether a session exists or not?"  
description: "How to check whether a session exists or not?"  
author: "Anonymous User"  
published: 2010-10-15  
updated: 2010-10-15  
canonical: https://www.mindstick.com/forum/42/how-to-check-whether-a-session-exists-or-not  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# How to check whether a session exists or not?

How to [check whether](https://www.mindstick.com/forum/157543/write-a-java-program-to-check-whether-a-string-is-a-palindrome) a [session](https://www.mindstick.com/articles/12042/session-in-c-sharp) [exists](https://www.mindstick.com/forum/158947/how-do-you-use-the-exists-operator-to-check-for-the-existence-of-records-in-a-subquery) or not?

I want to do this on each [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page), if not exist I will just send the [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) back to the sign in page. ![How to check whether a session exists or not?](https://www.mindstick.com/app_images/htmleditor.icons/eusa_whistle.gif)\

## Replies

### Reply by Anonymous User

thank you\

### Reply by Uttam Misra

Use this code for Session_Start event in global.asax file:

```
void Session_Start(object sender, EventArgs e)
    {
        if (User.Identity.IsAuthenticated)
        {
            System.Web.Security.FormsAuthentication.SignOut();
            System.Web.Security.FormsAuthentication.RedirectToLoginPage();
        }
    }
```


---

Original Source: https://www.mindstick.com/forum/42/how-to-check-whether-a-session-exists-or-not

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
