SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to give session time out.

    I want to give session time out...
    how to do this...where and what i have to write for this?
    I m using asp.net 2.0 with c# in visual studio 2005.
    I want to give different time for different user.
    Like i have 4 type of users in my project.

    Admin
    supervisor
    technician
    normal user

    for admin i m taking usergrouptype =1
    for supervisor usergrouptype=2
    for technician usergrouptype=3
    and
    for normal user usergrouptype=4.

    How to do this?
    Please Help.

  2. #2
    SitePoint Addict kunalraj's Avatar
    Join Date
    Nov 2008
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello,

    Are you working on window authentication mode or form authentication mode?

    http://forums.asp.net/p/1374263/2883659.aspx#2883659


    hope above link can understand you.


    thanks,
    kunalraj

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kunalraj View Post
    hello,

    Are you working on window authentication mode or form authentication mode?

    http://forums.asp.net/p/1374263/2883659.aspx#2883659


    hope above link can understand you.


    thanks,
    kunalraj
    m working on window authentication mode

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by yogita View Post
    m working on window authentication mode
    <?xml version="1.0"?>
    <!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
    -->
    <configuration>
    <appSettings>
    <add key="connectionstring" value="Data Source=TEST01;User id=IMS; Password=IMS"></add>
    </appSettings>
    <connectionStrings/>
    <system.web>
    <!--
    Set compilation debug="true" to insert debugging
    symbols into the compiled page. Because this
    affects performance, set this value to true only
    during development.
    -->
    <compilation debug="true">
    <assemblies>
    <add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
    <!--
    The <authentication> section enables configuration
    of the security authentication mode used by
    ASP.NET to identify an incoming user.
    -->
    <!--
    <siteMap defaultProvider="IMS_SiteMapProvider" enabled="true">
    <providers>
    <add name="IMS_SiteMapProvider" type="System.Web.XmlSiteMapProvider" securityTrimmingEnabled="true" siteMapFile="web.sitemap"/>
    </providers>
    </siteMap>
    -->
    <authentication mode="Windows"/>

    <!--
    The <customErrors> section enables configuration
    of what to do if/when an unhandled error occurs
    during the execution of a request. Specifically,
    it enables developers to configure html error pages
    to be displayed in place of a error stack trace.

    <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
    <error statusCode="403" redirect="NoAccess.htm" />
    <error statusCode="404" redirect="FileNotFound.htm" />
    </customErrors>
    -->
    </system.web>
    </configuration>

  5. #5
    SitePoint Addict kunalraj's Avatar
    Join Date
    Nov 2008
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    ok this is your web config file.

    I have not knowledge about how to work on session in .net but little bit i know.

    1.) in your aspx source page there should be write
    <&#37;@ Language=C# EnableSessionState=true %>

    2.)
    in web.config file you have to set time interval for session like

    <configuration>
    <system.web>
    <sessionState mode="Inproc"
    cookieless="false"
    timeout="20"/>//here you can set time in minute
    </sessionState>

    </system.web>
    </configuration>

    3.)
    create session for user which i think you know.

    so when user will idle for 20 minute session will automatically expire.
    I know upto this if i got any information i will inform you.

    Also refer this link it will help you.
    http://msdn.microsoft.com/en-us/libr...83(VS.71).aspx

    http://forums.asp.net/p/1374263/2883659.aspx#2883659



    thanks,
    kunalraj

  6. #6
    SitePoint Addict kunalraj's Avatar
    Join Date
    Nov 2008
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    in web config you can also set like this,

    <system.web>
    <authentication mode="Forms"/>///in ur config there is windows change it and write Forms
    <sessionState mode="InProc" cookieless="false" timeout="20">
    </sessionState>

    </system.web>

  7. #7
    SitePoint Addict kunalraj's Avatar
    Join Date
    Nov 2008
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey,

    I got this solution hope this will help you.

    U need to set the session time in three places..

    1.After Keeping the values in the session then set the session timeout value like this..


    Session["User"] = name1;//this session created
    //after create seesion write timeout
    Session.Timeout=600;

    2.set the session in web.config file

    <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="1"/>//1 in minute

    3.Set the session value in IIS also.

    In IIS, right click go to properties.

    click configuration button--go to options menu and set the session time out there also.

    I hope this will help you.


    thanks,
    kunalraj

  8. #8
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kunalraj View Post
    hey,

    I got this solution hope this will help you.

    U need to set the session time in three places..

    1.After Keeping the values in the session then set the session timeout value like this..


    Session["User"] = name1;//this session created
    //after create seesion write timeout
    Session.Timeout=600;

    2.set the session in web.config file

    <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="1"/>//1 in minute

    3.Set the session value in IIS also.

    In IIS, right click go to properties.

    click configuration button--go to options menu and set the session time out there also.

    I hope this will help you.


    thanks,
    kunalraj

    I didn't get this..n finding this one difficult

  9. #9
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <sessionState
    mode="InProc"
    stateConnectionString="tcpip=127.0.0.1:42424"
    sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    cookieless="false"
    timeout="1"
    />
    i m writing this code and its working....but now after 1 min if the user is clicking on anything the code file gets open. Here i want to display message that session is expired and want to redirect it to login page...how to do this?

  10. #10
    SitePoint Addict kunalraj's Avatar
    Join Date
    Nov 2008
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    try like this,

    1. In the Page_Load function (can be Master page too) I wrote next code :
    Response.AppendHeader("Refresh", Convert.ToString(Session.Timeout * 1) & ";
    URL=Timeout.aspx")//Timeout.aspx page you have to create and write below code
    2. In the Timeout.aspx after before </head > I wrote next code:
    <script type="text/javascript" language="javascript">
    function endSession()
    {
    alert("Your session has expired. You will be redirected to the login page.");
    url = '<%=mstrLoginURL %>';
    document.location=url;
    }
    registerLoadTask('endSession()')
    </script>

    3) In the Timeout.aspx in the Page_Load function I wrote next script:
    If Not IsPostBack Then

    mstrLoginURL = ResolveUrl("LogIn.aspx")
    End If


    Hope it will help you.


    thanks,
    kunalraj

  11. #11
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kunalraj View Post
    hi,

    try like this,

    1. In the Page_Load function (can be Master page too) I wrote next code :
    Response.AppendHeader("Refresh", Convert.ToString(Session.Timeout * 1) & ";
    URL=Timeout.aspx")//Timeout.aspx page you have to create and write below code
    2. In the Timeout.aspx after before </head > I wrote next code:
    <script type="text/javascript" language="javascript">
    function endSession()
    {
    alert("Your session has expired. You will be redirected to the login page.");
    url = '<%=mstrLoginURL %>';
    document.location=url;
    }
    registerLoadTask('endSession()')
    </script>

    3) In the Timeout.aspx in the Page_Load function I wrote next script:
    If Not IsPostBack Then

    mstrLoginURL = ResolveUrl("LogIn.aspx")
    End If


    Hope it will help you.


    thanks,
    kunalraj
    thanks its working


Bookmarks

Posting Permissions

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