...

View Full Version : Grabbing information from session



Athmaus
05-31-2005, 09:58 PM
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:



<%
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!

miranda
05-31-2005, 10:27 PM
user = Session("username")
pass = Session("password")
Response.Write("session(""username"") = " & Session("username") & "<br>")
Response.Write("user = " & user & "<br>")
Response.Write("session(""password"") = " & Session("password")& "<br>")
Response.Write("pass = " & pass & "<br>")

These do not write out the same info to the screen??

Athmaus
05-31-2005, 10:30 PM
sorry i forgot to put the error i am recieving:

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

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



user = Session("username")
pass = Session("password")
Response.Write("session(""username"") = " & Session("username") & "<br>")
Response.Write("user = " & user & "<br>")
Response.Write("session(""password"") = " & Session("password")& "<br>")
Response.Write("pass = " & pass & "<br>")

These do not write out the same info to the screen??

I do not want to response.write the info in the session, that is there to make sure that infor is being passed into the session.

I am trying to get that info that is in the session for that query

miranda
05-31-2005, 10:43 PM
it isn't pointing to the variable like you said here then....

I can "response.write" the infromatino that is in the session, yet i can not assign that information to a variable.

The problem is you have not got the connection object opened or you used a different one from the one that you opened.
this is your connection object as you opened it
Set verify = Server.CreateObject("ADODB.Connection")
verify.open = (your dsn or dsnless connection string goes here)

then you used
myconn.execute instead of verify.execute

Athmaus
05-31-2005, 10:47 PM
Dude you are awesome! i totally overlooked that. Thank you sooo much, that fixed it

Freon22
05-31-2005, 10:55 PM
Not fast enough in my post.

miranda
05-31-2005, 11:31 PM
you are welcome.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum