Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Loosing my session variable
Old 08-24-2005, 10:20 AM Loosing my session variable
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Hi,
refering to http://www.collagenrx.co.uk/Student%20Space/home.asp

I set 2 session variables on the above login screen.

After you log in (username steve password admin) you can see to the left above the navigation that the session variable is shown. (steve)
My problem is that it resets after a very short period of time.
Each page I call beyon login checks the value of session variable and if not exist then redirects to the home page.

Code:
 if Session("loggedIn") = "no" OR Session("loggedIn") = "" then
	response.redirect "home.asp"
 end if
If you messa round looking at stats etc and going through pages, all works fine and then suddenly, the session variable is reset and i am redirected to home.asp only after a minute or so if that.


Is there a logical reason why I am not able to hold the session variable.

Steve
__________________

Please login or register to view this content. Registration is FREE

Last edited by numbenator; 08-24-2005 at 10:24 AM..
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 08-29-2005, 12:30 AM
Novice Talker

Posts: 12
Location: Denver, Colorado
Trades: 0
If you have access to your servers session timeout value - that could be the problem. The other thing is that if you are logged in and click on Home - it automatically logs you out - do you clear the session at the home.asp page?
__________________

Please login or register to view this content. Registration is FREE
:: A denver based web design, web marketing, and asp development company.
ccdesigns is offline
Reply With Quote
View Public Profile Visit ccdesigns's homepage!
 
Old 08-30-2005, 04:19 AM
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
No, The session is not cleared in home.asp. The code related to the session variable is below :

Code:
if request.form("submit") <> "" then 
  if request.form("submit") = "login" then
  
	username = request.form("username")
	password = request.form("password") 
	
	
	
	SQL = "SELECT * FROM users WHERE username = '"&username&"' and password='"&password& "'"
	Set RS = Conn.Execute(SQL)
	
	  if not (RS.EOF and RS.BOF) then
		' User Login Success
		Session("loggedIn")  = "yes"
		Session("User") = RS("fullname")
		Response.redirect("statistics.asp")
		
	  else
		' Login Fail
		response.write ("<script>alert('Invalid username or password. Please try again!');window.history.back();</script>")
	  end if
end if
end if
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 09-02-2005, 02:14 AM
PremiumHost's Avatar
Average Talker

Posts: 23
Trades: 0
Everything is correct. Maybe problem from the server. Session time out is too short ??
__________________

Please login or register to view this content. Registration is FREE

Proudly to be a reliable host for 5000+ domains
Linux Reseller Cpanel 11 - Windows Reseller Helm ASP.NET 3.5 SQL 2005
PremiumHost is offline
Reply With Quote
View Public Profile
 
Old 09-03-2005, 04:08 PM
WebcyteDesign's Avatar
Registered User

Posts: 159
Location: Hamilton
Trades: 0
why don't you just declare the timeout in the code or better yet use cookies. In order to use session variables you need to have cookies activated anyways so why not use something that isn't going to timeout on you.
WebcyteDesign is offline
Reply With Quote
View Public Profile Visit WebcyteDesign's homepage!
 
Old 09-12-2005, 06:30 PM
HostTester's Avatar
Novice Talker

Posts: 6
Location: Ohio
Trades: 0
Do you have a global.asa for the application? If so you can adjust your default session time out in the Session_OnStart() there, just add a line that says:
Session.Timeout = 30 '(that'd be for 30 minutes)

If you don't have the global.asa set up then just set it on your login page where you set your session variable to begin with. Cookies are also a good idea if you want to carry the information over many days, but usually login stuff is just for the current session for security reasons so a session variable like you are using is probably the better idea.

If the Session.TimeOut line doesn't help then you must have something in another page that is resetting your variable to log you back out.

Good luck!
__________________
Chuck Hall

Please login or register to view this content. Registration is FREE

What's Your Uptime?
HostTester is offline
Reply With Quote
View Public Profile Visit HostTester's homepage!
 
Reply     « Reply to Loosing my session variable
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33979 seconds with 12 queries