title: Passing session or cookie variables to server tags in ASP.NET
body: <p>This is probably a simple question but, it eludes me, I have a variable that I have set as a code-behind session in another page of an ASP.NET application. Let's say it is: <code>Session["UserName"]</code> and I want to pass it from a code behind page to the server tag. The server tag looks like this:</p>
  
  <p><code>&lt;asp:SqlDataSource ID="SqlDataSourceDelta" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ConnectionStringAlpha %&gt;" SelectCommand="SELECT [ThingTitle], [ThingSynopsis], [ThingCategory], [ThingType], [ThingUserName] FROM [ThingOfSubmissions] WHERE ThingUsername = &lt;%$ Session["UserName"] %&gt;"</code></p>
  
  <p>I can't use: <code>&lt;%$ Session["UserName"] %&gt;</code> directly in the server tag as shown above without it generating an error about mal formed server tags. So my question is, how can I pass this session  variable or any other application variable (non SQL Server variable) into this bit of code?</p>