aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Get Access Session Variable Value in

Jun 23, 2013

Here I will explain simple jQuery code to get / access session variable value in jQuery or how to access or get session variable value using jQuery in


In previous articles I explained jQuery slideup, slidedown and toggle effects example, jQuery Draggable & Resizable div with example, jQuery split the string jQuery Scrollable gridview with fixed header and many articles relating to JQuery, JavaScript,, code snippets. Now I will explain how to access or get session variable value using jQuery in

Get or Access Session Variable value in jQuery

To get or access session variable value in jQuery we need to write the code like as shown below

var name = '<%= Session["UserName"] %>'
In above code Session["UserName"] is the value what we set in session. If you want to see it in complete example check below code

<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(function() {
var name = '<%= Session["UserName"] %>'
<label id="lbltxt" />

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Siva Nomula said...

I regularly view all your samples, your solutions are simple but effective.
In the above example, server tags used to retrieve Session Variable, jquery is not used.
Please correct me if i am wrong

sanju said...

Very Nice !!!

Irtekaz Ahmed Khan said...

your post interested thanks sir

Anonymous said...


Unknown said...

how to save the history

satish reddy said...

your post is nice.but my doubt is if i take the name session["username"] dynamically then how can i get the value in javascript.and first javascript code is executed next serverside code is executed

Daniel said...

I have a query, What if the session is empty? How can we handle it? Could you pls explain..?

Anonymous said...

This solution does not work....

Anonymous said...

jQuery not used in this code.
if you need to use jQuery then use the jQuery plugin to set and get the session variable.

Unknown said...

Great Post!!!
This is What I was looking For.
Thank you.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.