Results 1 to 3 of 3

Thread: Ajax: Session

  1. #1
    Join Date
    Mar 2013
    Posts
    270

    Ajax: Session

    Hi,

    I want ask about ajax scipt. My page keep loop. What i know session store in database.
    Code:
     function checkSession(){
            $.ajax({
                url: CHECK_SESSION_URL,
                type:'post',
                dataType: 'json',
                success: function(e){
                    if(e.status == 1){
                        location.reload();
                    }else{
                        setTimeout(checkSession, 5000);
                    }
                }
            });
        }
    What does this script do? Please advice.

    Thanks.

  2. #2
    Join Date
    Aug 2007
    Posts
    905
    Looks like if it sends a request to CHECK_SESSION_URL (this will be defined in a config file or something), and if the request is successful it reloads the page. if not, it waits 5 seconds and checks again.
    Some useful tutorials for VPSes...
    Set up an unmanaged Linux VPS to host websites
    (avoid having to pay for cPanel)
    Install a GUI on a Linux VPS with RDP (cheap alternative to paying for a Windows license if you need a basic remote workstation)

  3. #3
    1. Is jquery .

    2. CHECK_SESSION_URL, - is url defined somehere above .

    3. this code require server background that at url {CHECK_SESSION_URL} must reply in json format .

    4. if field of json response "status" equal 1 ( set in some background code , may be in php ) then reload page . Seem mean that session is wrong .

    5. else - set timeout to recheck session in 5 secs again .

    good news - seem code in backgorund response , bad news seem not working if reload . simplest suggestion - try another browser . other will require investigation .
    << Please review signature guidelines >>

Similar Threads

  1. Replies: 1
    Last Post: 07-04-2010, 08:16 AM
  2. Invalidate session - session timeout or setMaxInactiveInterval() ???
    By JavaDziner in forum Programming Discussion
    Replies: 0
    Last Post: 03-01-2010, 01:50 PM
  3. Replies: 0
    Last Post: 06-26-2009, 08:26 PM
  4. session
    By orbitz in forum Programming Discussion
    Replies: 3
    Last Post: 06-15-2006, 01:57 PM
  5. session help
    By Gamenati in forum Programming Discussion
    Replies: 3
    Last Post: 05-20-2003, 04:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •