Hello Friendz,
I am stuck up with a peculiar problem.
My requirement is that when the user logs in the client side time should be saved and should be displayed on the screen.
So on our LMS Bangalore software's page I have written a JavaScript which captures the client side time and stores it in a hidden field. Then on the click of the log in button I am storing it in the Session["Clienttime"] and then displays it on the Create Employee page when the page opens.
Here is my JavaScript code:
<script language="javascript" type="text/javascript">
function EncryptMD5()
{
var Pass = document.getElementById("<%=txtPassword.ClientID%>").value;
// Encrypte the password
if (Pass.length > 0 )
{
var MD5Hash = hex_md5(Pass);
var salt = document.getElementById("<%=SaltStr.ClientID%>").value;
MD5Hash = hex_md5(salt+MD5Hash);
document.getElementById("<%=HashPass.ClientID%>").value = MD5Hash;
document.getElementById("<%=txtPassword.ClientID%>").value = MD5Hash;
}
DisplayDateTime()
}
function DisplayDateTime()
{
var DateTime = new Date();
var strYear= DateTime.getYear();
var strMonth= DateTime.getMonth() +1;
var strDay = DateTime.getDate();
var strHours = DateTime.getHours();
var strMinutes = DateTime.getMinutes();
var strSeconds = DateTime.getSeconds();
var clientTime = strDay + "/" + strMonth + "/" + strYear + " " + strHours + ":" + strMinutes + ":" + strSeconds;
document.getElementById("<%=hfClientTime.ClientID%>").value = clientTime;
}
</script>
Then I do this on log in buttons click:
Session["Clienttime"] = hfClientTime.Value.ToString();
and in my .aspx page i call javascript:
OnClientClick="EncryptMD5()"
and on my employee page I want to display the time so do this:
lblTime.Text = Session["Clienttime"].ToString();
The problem is when I log for the first time everything works fine. But then when I log out or close the page and again logs in I find the session cleared despite evertime assigning the time value on the login buttons click.
Can u tell me where I am going wrong?
Thanking You
Swapnil Borkar.