using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.SessionState;

public partial class Security_ExecSecurityBanner : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
        this.Form.DefaultButton = this.btn_agree.UniqueID;
        Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
        Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
        Response.AppendHeader("Expires", "0"); // Proxies.

        if (Session["pageArea"] as string != "L")
        {
            if (!String.IsNullOrEmpty(Session["uid"] as string))
                Helper.LogOut(Session["uid"].ToString());
              
            HttpContext.Current.Session.Clear();
            HttpContext.Current.Session.Abandon();
            //HttpContext.Current.Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));

            Response.Redirect("../Security/LoginPage.aspx");
        }

        if (!IsPostBack)
             ChangeSessionID();
    }
    private void ChangeSessionID()
    {
        return;
        System.Web.SessionState.SessionIDManager iManager = new System.Web.SessionState.SessionIDManager();
        string oldSessionId = iManager.GetSessionID(Context);
        string newSessionId = iManager.CreateSessionID(Context);
        bool isAdd = false, isRedir = false;
        iManager.SaveSessionID(Context, newSessionId, out isRedir, out isAdd);
        HttpApplication ctx = (HttpApplication)HttpContext.Current.ApplicationInstance;
        HttpModuleCollection mods = ctx.Modules;
        System.Web.SessionState.SessionStateModule iSessionStateModule = (SessionStateModule)mods.Get("Session");
        System.Reflection.FieldInfo[] ifields = iSessionStateModule.GetType().GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
        SessionStateStoreProviderBase store = null;
        System.Reflection.FieldInfo iRqIdField = null, iRqLockIdField = null, rqStateNotFoundField = null;
        foreach (System.Reflection.FieldInfo field in ifields)
        {
            if (field.Name.Equals("_store")) store = (SessionStateStoreProviderBase)field.GetValue(iSessionStateModule);
            if (field.Name.Equals("_rqId")) iRqIdField = field;
            if (field.Name.Equals("_rqLockId")) iRqLockIdField = field;
            if (field.Name.Equals("_rqSessionStateNotFound")) rqStateNotFoundField = field;
        }
        object lockId = iRqLockIdField.GetValue(iSessionStateModule);
        if ((lockId != null) && (oldSessionId != null)) store.ReleaseItemExclusive(Context, oldSessionId, lockId);
        rqStateNotFoundField.SetValue(iSessionStateModule, true);
        iRqIdField.SetValue(iSessionStateModule, newSessionId);
    }
    protected void btn_agree_Click(object sender, EventArgs e)
    {
        Session["pageArea"] = "A";
        ExceptionUtility.LogException(0, "", "", "btn_agree_Click", "");
        Response.Redirect("../Business/Default.aspx");
        
    }
}