Forum  Core :: SDK (Vi...  Using the Visua...  Automatic Logout when user is idle
Previous Previous
 
Next Next
New Post 5/4/2009 8:03 AM
Unresolved
  samsuree
38 posts
No Ranking


Automatic Logout when user is idle 

Hi,

   I need to logout after a few mins when the user is idle. I have gone through with below forum link thread,

http://www.visualwebgui.com/Developers/Forums/tabid/364/forumid/27/threadid/18701/scope/posts/threadpage/3/Default.aspx

but i was not able to access the methods in the custom control. I have created a custom control named SessionTimeOut and i have copied and pasted the code accordingly after that i was not able to call the register() and other methods in the customcontrol. Kindly correct me know if i am doing something wrong and if any one have an alternative solution do let me know please.

 


Regards, Suresh A Winwire Technologies www.winwire.com
 
New Post 5/5/2009 12:36 AM
  ori.cohen
4383 posts
1st Level Poster




Re: Automatic Logout when user is idle 

Hello Suresh A,

Please view my first post this thread here for information.

Please don't read the following before reading my post in the referenced thread above:
If you set the KeepConnectedLimitation to 1 and leave the KeepConnectedInterval at 120000, after two minutes if there is no further action made by the user on the Form, it would be completely up the the settion timeOut setting to keep the session alive.
The session object will be killed after (((KeepConnectedInterval * KeepConnectedLimitation)/60000) + session.timeOut) minutes after the last user action.

For example (using the same equation):
(((1 * 120000)/60000) + 4) minutes = 6 minutes.

Regards,

Ori Cohen
Support Manager, the Visual WebGui team

 
New Post 5/5/2009 3:51 AM
  samsuree
38 posts
No Ranking


Re: Automatic Logout when user is idle 
Modified By samsuree  on 5/5/2009 6:29:44 AM)

Hi Ori Cohen,

    I will tell you what i have done in my application. I have created an user control and named it as SessionTimeout. And i have pasted the below code:

SessionTimeout.js

var timerPassCount = 0;
var timer; //used to check at every 20 sec the user intercation
var mTimeOut; //is the timeout in seconds specified in sessionstate tag from web.config
var mStrGuid;

function alertMessage() {
    Invoked");
}

function InitSessTimeOut(timeout) {
    mTimeOut = timeout;
    //mStrGuid = strGuid;
    document.body.onmouseover = function() { OnMove() };
    document.body.onkeypress = function() { OnMove() };
    //call the function at 10 sec
    timer = setTimeout("timedCount()", 20000);
}

function OnMove() {
    if (timerPassCount != 0) {
        timerPassCount = 0;
    }
}

function timedCount() {
    timerPassCount += 20;
    if (timerPassCount >= mTimeOut) {
        //log out the user
        Events_CreateEvent("LogSesOut", true);
        Events_RaiseEvents();
        return;
    }
    //call the function at 10 sec
    timer = setTimeout("timedCount()", 20000);
}

function LogOut() {
    clearTimeout(timer);
}

 

SessionTimeout.cs

#region Using

using System;
using System.Text;
using System.Data;
using System.Drawing;
using System.ComponentModel;
using System.Collections.Generic;

using Gizmox.WebGUI;
using Gizmox.WebGUI.Forms;
using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms.Design;
using Gizmox.WebGUI.Common.Interfaces;
using Gizmox.WebGUI.Common.Extensibility;

#endregion

namespace Test

{
    /// <summary>
    /// Summary description for SessionTimeout
    /// </summary>
    [ToolboxItem(true)]
    [ToolboxBitmapAttribute(typeof(SessionTimeout), "Test.SessionTimeout.bmp")]
    [DesignTimeController("Gizmox.WebGUI.Forms.Design.PlaceHolderController, Gizmox.WebGUI.Forms.Design, Version=2.0.5701.0, Culture=neutral, PublicKeyToken=dd2a1fd4d120c769")]
    [ClientController("Gizmox.WebGUI.Client.Controllers.PlaceHolderController, Gizmox.WebGUI.Client, Version=2.0.5701.0, Culture=neutral, PublicKeyToken=0fb8f99bd6cd7e23")]
    public partial class SessionTimeout : Gizmox.WebGUI.Forms.Component
    {
        public delegate void LogOutFct();
        public event LogOutFct LogOutEvent;

        public SessionTimeout()
        {
            InitializeComponent();
        }

        public void Register()
        {
            this.RegisterSelf();
        }

        public void SetTimeOut(int timeOut)
        {
            this.InvokeMethod("alertMessage");
            this.InvokeMethodWithId("InitSessTimeOut", new object[] { timeOut });
        }

        public void LogOut()
        {
            //stop the client timer
            this.InvokeMethodWithId("LogOut");
        }

        public void Unregister()
        {
            this.UnRegisterSelf();
        }

        protected override void FireEvent(IEvent objEvent)
        {
            switch (objEvent.Type)
            {
                case "LogSesOut":
                    {
                        if (LogOutEvent != null)
                            LogOutEvent();
                    }
                    break;
                default:
                    base.FireEvent(objEvent);
                    break;
            }
        }
    }
}

 

SessionTimeout.Designer.cs

namespace Test
{
    partial class SessionTimeout
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            components = new System.ComponentModel.Container();
        }

        #endregion
    }
}
 

 

FrmMain.cs

And in my main form (which is displayed once the login is successful) i have created a timer and named it as SessionTimer and i have done the below in the main form,

frmMain_Load()

{

SessionTimer.start();

}

 

private void SessionTimeoutTimer_Tick(object sender, EventArgs e)
        {

            sessionTimeout.Register();
            sessionTimeout.LogOutEvent += new SessionTimeout.LogOutFct(sessionTimeOut_LogOutEvent);

            //20 mins by default
            int sessTimeOut = 1200;//1200;
            System.Web.Configuration.SessionStateSection sessionState = System.Configuration.ConfigurationManager.GetSection("system.web/sessionState") as System.Web.Configuration.SessionStateSection;
            if (sessionState != null)
                //sessTimeOut = (int)sessionState.Timeout.TotalSeconds;

                //sessionTimeout.SetTimeOut(sessTimeOut - SessionTimeoutTimer.Interval / 1000);
                sessionTimeout.SetTimeOut(((1 * 120000) / 60000) + 4);
            SessionTimeoutTimer.Stop();
        }

void sessionTimeOut_LogOutEvent()
        {
            //logout the session
            this.Context.Session.IsLoggedOn = false;
        }
 

I have kept a breakpoint in the SessionTimeout.js in the function InitSessTimeOut(timeout) it doesnt hit the breakpoint at all. Also i have found that in the SessionTimeout.cs file with the below function,

public void SetTimeOut(int timeOut)

{
            this.InvokeMethod("alertMessage");
            this.InvokeMethodWithId("InitSessTimeOut", new object[] { timeOut });

}
 

when i see the QuickWatch i am getting the below message "Expression has been evaluated and has no value".

Kindly let me know if i am going wrong somewhere. And i have waited for more than 10 mins and nothing has happened.


 


Regards, Suresh A Winwire Technologies www.winwire.com
 
New Post 5/5/2009 6:17 AM
  ori.cohen
4383 posts
1st Level Poster




Re: Automatic Logout when user is idle 

Hello Suresh A,

It is very hard for us to process applications we get in this fashion. It would be too easy to miss things this way.

Please send us your application to Support [at] VisualWebGui [dot] com with a link to this forum thread. Please also clean the solution before sending and reply to this post with the subject of your support request, so I would know to check for it.

Before sending, please make sure you understand all that I explained before. It is crucial for acheiving successful timed log-outs.

Regards,

Ori Cohen
Support Manager, the Visual WebGui team

 
New Post 5/6/2009 1:56 AM
  samsuree
38 posts
No Ranking


Re: Automatic Logout when user is idle 

Hi Ori Cohen,

   I have solved the problem with a simple workaround. Thanks a lot.


Regards, Suresh A Winwire Technologies www.winwire.com
 
Previous Previous
 
Next Next
  Forum  Core :: SDK (Vi...  Using the Visua...  Automatic Logout when user is idle
Assessment Bottom
.NET Web, Cloud and Mobile application delivery platform | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2011 Visual WebGui®       Visual WebGui weblog on ASP.NET Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS