Words on my addictions: .NET, Philosophy, Music

14 February 2005

Struct[SessionTable]

Filed under: C# — stefanprodan @ 12:11 pm

I am trying to make a check function for the SessionState.. here is some code for this try:

public struct SessionTable
{
public string[] data;
public string this[int index]
{
get { return data[index]; }
set { data[index] = value; }
}

public SessionTable(HttpSessionState HS)
{
data = new string[HS.Count];
for (int i = 0; i < HS.Count; i++)
{
data[i] = HS.Keys[i].ToString();
}
}
}

I am using a class named master.cs to handle the data transfer betuin pages in my site. Here is the code:

public class master : Page
{
public bool SessionValidation(SessionTable ST, HttpSessionState HS) {
bool rez = true;
for (int i = 0; i < ST.data.Length; i++)
{
if (HS[ST.data[i]] == null)
{
rez = false;
}
}
return rez;
}

public master()
{
this.EnableViewState = true;
}

public SessionTable sTable
{
get { return (SessionTable) (Application[Session.SessionID]); }
}

}

Now in the an aspx page when I want to see if the session is not corupted I do this:

private void SaveToSessionTable()
{
Application.Set(Session.SessionID,ST);
}

private bool ValidateSession()
{
return SessionValidation(this.sTable,Session);
}

Much more to do… but is a start poin…

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: