i m using session in my website(ASP) but after logging in if i don't acccess the page for 5 minutes session expires n if i continously access some pages then after 15 minutes session expires.i have used global.asa file then same problem occurs and if i dont use global.asa then also problem remains same

I am assisgning values to session while authorized person loggs in.


i have made a seperate page for checking if session value is empty or unauthorized user try to access the page redirect user to unauthorized page.

can it be possible that the person remains logged in until n unless
he/she logs out manually.

Recommended Answers

All 4 Replies

Try to use the session.timeout method


<%
session("username") = "abc"
Session.Timeout = 50
%>


By default your session is valid for 20 mins if u r not active. But in the above code, your session will expire after 50 minutes even if u r not active

I will suggest you to change your code like this.

<sessionState 
        mode="StateServer"
        cookieless="false" 
        timeout="900"/>

Here I have changed the session state to a seperate worker process (ASP state management server).

It is recommended to move your session into the stateserver or SQL server state management in the production environment.

Note: You need to start the 'ASP.NET State Service' windows service on the web server in order to make this code work.


Johnlee Sam

i m using session in my website(ASP) but after logging in if i don't acccess the page for 5 minutes session expires n if i continously access some pages then after 15 minutes session expires.i have used global.asa file then same problem occurs and if i dont use global.asa then also problem remains same

I am assisgning values to session while authorized person loggs in.


i have made a seperate page for checking if session value is empty or unauthorized user try to access the page redirect user to unauthorized page.

can it be possible that the person remains logged in until n unless
he/she logs out manually.

unlimited sesion is not possible anyway u can fix it to mre time by specifying session.timeout=0

I hope you wont mind but it happend with me that even after assigning some value to Session.Timeout I'm not able to access my website pages as an authenticated user.

Let me explain my situation, I've developed an web application where in a particular module I'm having three pages say page1.asp, page2.asp and page3.asp .

Now the working is :
An user will login with username and password.
If the username and password matches any of the username/password in the database then a session variable is defined and a default value is assigned for instance - session(user) = "true" - else he/she will be redirected to the login.asp page.

Now the authenticated user of the application will have to provide some details in the first page that is page1.asp, then on submission of the page it is redirected to page2.asp where again the user has to provide some more details. He will be having 20 to 30 fields to fill in this page(page2.asp). But as soon as page2.asp is submitted, it is redirecting to the login.asp page.

Further more, I must say that I'm using a login check for all the pages where only the authenticated users will have access. That is before every page is loaded it checks whether the user who is trying to access is authenticated or not. As I told, if the user is not authenticated it redirects the user to the login.asp page.

Now, as I've gone through the aforesaid situation time and again, in my view this is happening because the condition for the session variable (session(user)= "true") is false. That is the session is expiring before time.

So if anyone who brings light to my situation will be highly appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.