How do you make a JavaScript session?
if (gameWin) {
Session["BrugerTid"] = document.all("counter").innerHTML;
window.location = "Won.aspx";
}
var timeLeft = 120;
function decrementCounter() {
if (timeLeft > 0) {
document.all('counter').innerHTML = "" + timeLeft + "";
timeLeft--;
setTimeout("decrementCounter()", 1000);
document.getElementById("start_button").style.display = 'none';
document.getElementById("blackout").style.display = 'none';
}
else {
window.location = "Failed.aspx";
}
}
You cannot access the Session object (server-side) directly from javascript (client-side), but maybe you could send the time to your .aspx page as a parameter instead?
Like this in javascript:
if (gameWin) {
window.location = "Won.aspx?BrugerTid=" + document.all("counter").innerHTML;
}
And in Win.aspx:
protected void Page_Load(object sender, EventArgs e)
{
Session["BrugerTid"] = Request.QueryString["BrugerTid"];
}