I am trying to get session stating working with certain specifications
right now, and am running into an issue I can't peg. I currently have
session stating running have changed my web.config file to SQLstate and
ran the installsqlstate.sql script through the query analyzer. This is
all fine and good, however this application users integrated windows
authentication so I would assume it would write to the database,
however I am having trouble hooking this event to happen with the
default session stating.
This is what I have so far regarding the session stating and setting
the cookies.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebApplication1
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox user;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox pass;
protected System.Web.UI.WebControls.Label msg;
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter2;
protected System.Data.SqlClient.SqlCommand sqlSelectCommand2;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
public System.Data.DataSet dataSet1;
protected System.Data.DataTable dataTable1;
protected System.Web.UI.WebControls.Label msg1;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
Session["var"] = user.Text;
string sessio = Session["var"].ToString();
Response.Cookies["test"].Value = user.Text ;
DateTime dtime = DateTime.Now;
Response.Cookies["test"].Expires = DateTime.Now.AddMinutes(1);
SqlConnection conn = new
SqlConnection(sqlConnection1.ConnectionString);
conn.Open();
SqlCommand cmd1 = new SqlCommand("UPDATE userlogin SET
SessionID='"+sessio.ToString()+"', ClickTime = '"+dtime.ToString()+"',
ExpireTime='"+Response.Cookies["test"].Expires.ToString()+"',
Cookie='"+Response.Cookies["test"].Value+"' WHERE
UserID='"+user.Text+"'",conn);
cmd1.ExecuteNonQuery();
conn.Close();
}
Any ideas?