You can read the value of session at client side but can't initialized/write session at client side as it is a server object. Please use
HiddenField to save the date of client system as shown below in example.
<script type="text/javascript">
window.onload = function () {
var currentTime = new Date();
var fulldate = currentTime.getFullYear()
+ '-' + (parseInt(currentTime.getMonth()) + 1)
+ '-' + currentTime.getDate()
+ ' ' + currentTime.getHours()
+ ':' + currentTime.getMinutes()
+ ':' + currentTime.getSeconds()
+ ':' + currentTime.getMilliseconds();
document.getElementById('<%=hdnDate.ClientID%>').value = fulldate;
}
I hope this solution will help you.. :)
</script>
// Declaration of controls in <Body> tag of page..
<asp:hiddenfield id="hdnDate" runat="server" xmlns:asp="#unknown" />
<br />
<br />
<asp:button id="btnGetDate" runat="server" text="Button" onclick="btnGetDate_Click" xmlns:asp="#unknown" />
// On Button Click, You can access client date at server side with help of
hidden field..
protected void btnGetDate_Click(object sender, EventArgs e)
{
Response.Write(hdnDate.Value);
}