Home > ASP Development > Grabbing information from session

Grabbing information from session



Hello,

I have this site to where people can get access to via a username and passwrod. THere is also a download section in here, but i want to limit the amount of downloads, but i also am covering up where the download is located. So when someone hits download on the page, they get sent to an asp page. This asp page has a response.redirect to download the file.

I have stored the peoples username and password in a session. I can "response.write" the infromatino that is in the session, yet i can not assign that information to a variable. Any help you can provide will be appreciated:


Code:


<%
If Session("login") = FALSE Then
Response.Redirect "http://www.yahoo.com"
Else
 
Dim myconn, verify, blnLoggedIn, user, pass, site, logged, objRS, exceeded
Set verify = Server.CreateObject("ADODB.Connection")
verify.open = (SQL LOGIN STUFF GOES HERE)
 
Response.Write(Session("username")) 
Response.Write(Session("password"))
 
user = Session("username")
pass = Session("password")
 
 
exceeded = 5
 
Set objRS = myconn.execute("SELECT id, download, totaldl FROM testing WHERE username='" & user & "' AND pass='" & pass & "';")
 
If objRS.EOF Then '''NO RECORDS MATCH. USER DID NOT LOG IN CORRECTLY
blnLoggedIn = False
Response.Redirect "http://www.yahoo.com"
 
Else
If objRS("download") >= exceeded Then 'LOGGED IN AN ABNORMAL TIME
blnLoggedIn = false
Response.Redirect "http://www.google.com"
 
Else '''EVERYTHING PASSED PROCEEDE WITH DOWNLOAD
blnLoggedIn = True
verify.execute("UPDATE testing set download = (download + 1) , totaldl = (totaldl + 1) WHERE username='" & user & "' AND pass='" & pass & "';")
 
End If
End If
End If
%>
<html>
<head>
<title>Logged</title>
</head>
<body>
<%
Response.Redirect "http://ps2.ign.com"
%>
</body>
</html>




Thanks!

    
Guest


Quote:
yet i can not assign that information to a variable

hmm... and what exactly do you mean by that? you get error? you get empty variables? the server freak out when executing this code? we can't help without relevant details. also, is this code in the same page? does your browser has cookies enabled for the website domain? and finally, how did you debug the code?

Was this answer helpful ? Yes No   
Guest


use:

Code:


user = CStr(Session("username"))
pass = CStr(Session("password"))



Was this answer helpful ? Yes No   
Guest


sorry i forgot to put the error i am recieving:

Microsoft VBScript runtime error '800a01a8'
Object required: ''

this is line it is giving me the error on:


Code:


Set objRS = myconn.execute("SELECT id, download, totaldl FROM testing WHERE username='" & user & "' AND pass='" & pass & "';")




Quote:
Originally Posted by leuvenaar
use:

Code:


user = CStr(Session("username"))
pass = CStr(Session("password"))




that didnt work either gave me same error

Was this answer helpful ? Yes No   
Guest


either change this line:

Code:


Set verify = Server.CreateObject("ADODB.Connection



to this:

Code:


Set myconn = Server.CreateObject("ADODB.Connection



or change this line:

Code:


Set objRS = myconn.execute(...



to this:

Code:


Set objRS = verify.execute(...




I hope you can see what was wrong in your code.

Was this answer helpful ? Yes No   
Guest


dude you are awesome! i totally overlooked that. Thank you sooo much, that fixed it

Was this answer helpful ? Yes No   
Guest


how you managed to conclude from this error that "you can't grab session information" still puzzle me, but anyways I'm glad you got it working.

Was this answer helpful ? Yes No   
Guest


that is what was irritating me, i could response.write it yet in my objRS it said there was no object. So i didnt know what was going on. stupid me, since it has been a three day weekend vacation for me, i'll blame it on that

Was this answer helpful ? Yes No   
Guest


lol... always blame something else ah?
well, when getting error you have to think what cause it - in your case, the "object expected" refered to "myconn". and short glance in the code reveal that such variable was declared allright, but never assigned as object. following the logic of errors is essential skill in programming, hope you got it sharpened now...

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved