session variable for username
<p>Hey I am creating a forum where users can login and post ocmments in a forum, I want the username as a session variable so I can get it when they post a comment and insert the username in the db and also to display a hello user message.</p>

<p>Below is my login code:</p>

<pre><code>protected void Button1_Click(object sender, EventArgs e)
{
    DataSet ds = new DataSet();
    localhost.Service1 myws = new localhost.Service1();
    ds = myws.GetUsers();
    foreach (DataRow row in ds.Tables[0].Rows)
        if (txtusername.Text == System.Convert.ToString(row["username"]) &amp;&amp;
        txtpassword.Text == System.Convert.ToString(row["password"]))
        {
            System.Web.Security.FormsAuthentication.RedirectFromLoginPage(txtusername.Text, false);
        }
        else
            Label3.Text = "Invalid Username/Password";
}
</code></pre>

<p>Do I declare the session variable here?</p>

<p>Like:</p>

<pre><code>Session["username"] = "username";
</code></pre>

<p>Also not sure what to type to get the value username from the db</p>

<p>Thanks</p>
