how do i find the status of loginstatus?
Hello
i am using visual studio and c# for a project at university. I have only just started using c#
I have a website which you can log in and out of. I have a lable on my site that contains text saying "you are logged in as:" next to it is the [loginname].
i want to be able to hide the lable when nobody is loged in. and reveal the lable when they are.
i know i can use .visible = true/false on the lable. i also realise it needs to be in an if statement.
How do i retrieve the status of the login status? i have tried putting
if (loginstatus = true)
when i do this it says:
"CS0118: 'System.Web.UI.WebControls.LoginStatus' is a 'type' but is used like a 'variable'"
is it possible to retrieve the status of the login status to use it as a condition?
Nikola 0Posted Jan 10, 2006, 3:49 PM
Upon verification of the user, create a session object and add it to the session state.
Session.Add("s_loginstatus", sessioncontents);
On your subsuquent pages, check to see if the session object exists:
if(Session["s_loginstatus"] == null)
{
LoginStatus.Visible = false;
}
else
{
LoginStatus.Visible = true;
}
sessioncontents is of type object