Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
<script type="text/javascript">
        var sessionID = getQuerystring('SessionID');
        var cookieSessionID = getCookie('session');
        var validNavigation = false;
 
        function endSession() {
            setCookie('session', sessionID, 1);
            var cookieSU = getCookie('session');
            if (cookieSU != null) {
                getSyncData('strSessionId=' + sessionID, 'UpdateUserLogoutSession');
            }
        }
 
        function wireUpEvents() {
            window.onbeforeunload = function () {
                if (!validNavigation) {
                    endSession();
                }
            }
 

            $('document').bind('keypress', function (e) {
                if (e.keyCode == 116) {
                    validNavigation = true;
                }
            });
 
            $("a").bind("click", function () {
                validNavigation = true;
            });
 
            $("form").bind("submit", function () {
                validNavigation = true;
            });
 
            $("input[type=submit]").bind("click", function () {
                validNavigation = true;
            });
 
        }
 
        $(document).ready(function () {
            if (cookieSessionID == null || cookieSessionID != sessionID) {
                // Do nothing
            } else {
                if (cookieSessionID == sessionID) {
                    getData('strSessionId=' + sessionID, 'UpdateUserResetSession', function (result) {
                        if (result['Exception']) { };
                    });
                }
            }
            wireUpEvents();
        });
 
        function setCookie(c_name, value, exdays) {
            var exdate = new Date();
            exdate.setDate(exdate.getDate() + exdays);
            var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
            document.cookie = c_name + "=" + c_value;
        }
        function getCookie(c_name) {
            var i, x, y, ARRcookies = document.cookie.split(";");
            for (i = 0; i < ARRcookies.length; i++) {
                x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
                y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
                x = x.replace(/^\s+|\s+$/g, "");
                if (x == c_name) {
                    return unescape(y);
                }
            }
        }
    </script>
 
Hey guys here i am calling
UpdateUserLogoutSession
in
window.onbeforeunload
event...
Now the problem is this works great on IE and Chrome..but it doesnt work on Firefox browser...
This function identify whether the page is REFRESHED or Closed........
So i want to use
UpdateUserResetSession 
on Refresh event and
UpdateUserLogoutSession
on close..!
 
Is there a way to do this in Firefox?
And Why it is not working?
One more thing....if i put
alert("hi");
after
setCookie('session', sessionID, 1);
            var cookieSU = getCookie('session');
            if (cookieSU != null) {
                getSyncData('strSessionId=' + sessionID, 'UpdateUserLogoutSession');
            }
it just works great..but when i try without alert..it doesnt work?
 
Whats the problem?
Posted 4-Sep-12 4:40am
Edited 4-Sep-12 4:48am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 505
1 Maciej Los 309
2 BillWoodruff 174
3 /\jmot 160
4 Suraj Sahoo | Coding Passion 160
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 4 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100