How to use session in JavaScript?

Posted by Tripati_tutu under JavaScript category on | Points: 40 | Views : 8170
To use session in JavaScript, write
var variableName='<%= Session("Value").ToString() %>'

Here the below code, which you can use as a session in JavaScript under <head> tag, but you can't use this in external JavaScript(.js) files.
<script type="text/javascript" language="javascript">
window.onload = function()
var sampleColor = '<%=Session["Color"]%>';

Comments or Responses

Login to post response