Description:

In this article, I will explain how to get session values on client side using Jquery.  

As we know, session is used to store information on server memory.

If we want to access session variables at client side, we can. But it has limitations.

On client side, we can only have read only access for the session variable.

To access session variable at client side,

var variable = '<%= Session["SessionVariable"] %>';

Example Program:

AssignSessionVal.aspx.vb:

protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext.Current.Session["JqueryJohn"] = "www.JqueryJohn.com";
        }

GetSessionVal.aspx:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            var SessionVal = '<%= Session["JqueryJohn"] %>';
            alert(SessionVal);
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
</html>

In the above example program, I assigned session values for the variable JqueryJohn on AssignSessionVal.aspx page. Now I am accessing the session variable on another page at client side using <%= Session["SessionVariable"] %>'.


Retreive Session value using Jquery, Get Session value with Jquery , How to call a Session variable in Jquery, How to get value of session in Jquery, Read Session value using Jquery, Session with Jquery, Find Session value using Javascript

1 comments:

 
Top