Create a new class
Csharp Code
Copy Code code as follows:
Using System;
Using System.Web;
Using System.Web.UI;
Using System.Web.SessionState;
public class Mana_session:page
{
Public Mana_session ()
{
}
protected override void OnInit (EventArgs e)
{
if (session["UID"]== null | | session["UID"]. ToString () = "")
{
Response.Redirect ("login.htm");
}
}
}
Copy Code code as follows:
Using System;
Using System.Web;
Using System.Web.UI;
Using System.Web.SessionState;
public class Mana_session:page
{
Public Mana_session ()
{
}
protected override void OnInit (EventArgs e)
{
if (session["UID"]== null | | session["UID"]. ToString () = "")
{
Response.Redirect ("login.htm");
}
}
}
In the CS file of the page that needs to judge the session, inherit the file from the Mana_session base class
For example
Csharp Code
public partial class Index:mana_session