<p>What is the best way to check for the existence of a session variable in ASP.NET C#?  </p>

<p>I like to use <code>String.IsNullOrEmpty()</code> works for strings and wondered if there was a similar method for <code>Session</code>.  Currently the only way I know of is:</p>

<pre><code> var session;
 if (Session["variable"] != null)
 {
     session = Session["variable"].ToString();
 }
 else
 {
     session = "set this";
     Session["variable"] = session;
 }
</code></pre>

That is pretty much how you do it.  However, there is a shorter syntax you can use.
```
```
sSession = (string)Session["variable"] ?? "set this";
```
```
This is saying if the session variables is null, set sSession to "set this"