How to check if a session variable exists. If (Session["LoggedIn"])

If I try it that way, I get can not convert to boolean. The only options I get when I type . to append a conversion does not include a conversion to boolean.

How can I check if a session variable exists before checking it’s value. This causes me problems.

When I looked into convert to boolean in the MSDN. How do you read this? I don’t understand it:
.NET Framework Class Library
Convert.ToBoolean Method (Boolean)

Returns the specified Boolean value; no actual conversion is performed.

public statibool ToBoolean(
bool value

I tried:

if (!Session[“LoggedIn”].Equals(null))

but getting not set to reference an instance of an object.

This works

(Session[“LoggedIn”]) !=null)

Why are you not using the builtin security framework? You should be using HttpContext.Current.User.IsAuthenticated . . .

I tried to use the login that the sitepoint book tries to teach to use. But I had a difficult time trying to tie in the users and the data that goes with them as they register. It just didn’t work the way I wanted them to. If you know another resource that teaches it. I’ll take a look at it and see if I can figure it out from there. So far this log in is mostly working for my customized wants.

That is what the personalization bits are for. Anyhow, check out this series of articles for anything and everything on Membership, Roles and Personalization.

Even if you want to go completely custom, you should still use the core of the builtin authentication and authorization features rather than an ASP.OLD session-style system.

Thank you so much for this.