C# .NET - How to redirect to a page in JQuery if session is alive

Asked By Daniel on 11-Nov-12 03:54 AM
Hi I have a page called login.aspx and another called MyAccount.aspx.Then what I want is when the user click on a link the system should check if the user  is already logged in, then redirect him to MyAccount.aspx if not it will redirect him to a login.aspx page.This is the code I am using to perform that,but it is not working:

$("#aha").live("click", function (e) {
       e.preventDefault();
       if ($.checkSessionExists(function(event,data){
        if(data.sessionExists){
         window.location.href=urlpath + "../MyAccount.aspx";
        }
        else{
        window.location.href=urlpath + "../Login.aspx";
        }
       });
     });
     });

Need your help!
kalpana aparnathi replied to Daniel on 11-Nov-12 04:49 AM
<script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script language="javascript" type="text/javascript">
      $(function() {
        setInterval(KeepSessionAlive, 10000);
      });
 
      function KeepSessionAlive() {       
        $.post("/Shared/KeepSessionAlive.ashx", null, function() {
          $("#result").append("<p>Session is alive and kicking!<p/>");
        });   
      }   
    </script>
    <h2>Will my session die?</h2>   
    <div id="result"></div>
Daniel replied to kalpana aparnathi on 11-Nov-12 05:42 AM
Hello!This is not the code I want.because it seems like this code in increasing the session of the user.
Please check my code.Because I what I want is to redirect to another page if the session is alive else to login.aspx