If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > help reading a cookie

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-08-04, 20:01
zobernjik zobernjik is offline
Registered User
 
Join Date: Feb 2004
Location: Australia
Posts: 183
Unhappy help reading a cookie

I am trying to create a login page for the first time, I have a login page, validate login page and if the password is correct it takes me to the first page.

I have customized this code someone else created,but what I have a problem with now is I need to log who submitted that data and that is why I am trying to read UserName cookie so I can later match that data.

This is the error I get which is telling me that it is reading the cookie since this is the UserName I am logging in with
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'boxhill'.

but I can't see what is wrong, and there is not much out there for this kind of error.

So I can login successfully but now i need to read and dispaly that cookie and then insert the value of the cookie but,but don't worry about that now, just trying to give you the full picture.

So this is the code for reading the cookie

Dim myCon
Dim rs

set myCon = Server.CreateObject("ADODB.connection")
set rs = Server.CreateObject("ADODB.recordset")

call myCon.Open(Application("MM_Shipment_ConnectionSTRI NG"))
call rs.Open("SELECT UserName FROM Logins " & _
" WHERE UserName=" & Request.Cookies("Login"), myCon)
Response.Write(rs("UserName"))
call rs.Close

Could somebody help me with this please.

thanks a lot
Reply With Quote
  #2 (permalink)  
Old 11-09-04, 19:06
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
You need single quotes around the value returned from the cookie since it's a string:

call rs.Open("SELECT UserName FROM Logins " & _
" WHERE UserName='" & Request.Cookies("Login") & "'", myCon)
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #3 (permalink)  
Old 11-09-04, 23:57
zobernjik zobernjik is offline
Registered User
 
Join Date: Feb 2004
Location: Australia
Posts: 183
Thumbs up

Thanks a lot, that worked like a dream.

This is the first time I am working with Cookies so I am very excited to learn something new.
Reply With Quote
  #4 (permalink)  
Old 11-10-04, 20:37
zobernjik zobernjik is offline
Registered User
 
Join Date: Feb 2004
Location: Australia
Posts: 183
Ok, so I was able to create the login,validate the login and get taken to a page where users enter and submit data and on that page I am also dispalying a UserName and also submitting the user name so I can later on match up who submitted what and where was it coming from,but there is a but.

When data is submitted by clicking on submit it takes me to Save.asp and then I redirect the page after 2 seconds to go back to First.asp page where users can enter more recrods if needed,but the value of my cookie is not disaplyed any more,so technically they are still logged in but I need to be able to dispaly the cookie which is a UserName all the time since I need them to submit that UserName for every record they enter.

So this is just how I display the UserName

set myCon = Server.CreateObject("ADODB.connection")
set rs = Server.CreateObject("ADODB.recordset")
call myCon.Open(Application("MM_Shipment_ConnectionSTRI NG"))
call rs.Open("SELECT UserName FROM Logins " & _
" WHERE UserName='" & Request.Cookies("Login") & "'", myCon)
Response.Write(rs("UserName"))
call rs.Close

and for saving the Cookie value, it is just part of my insert statement.


So what do I need to do to get the Cookie value=UserName to stay displayed when the page is redericted after users submitted their first record.

Hope this makes sense and somebody can help me.

Thanks a lot



PLEASE IGNORE I JUST HAD A LITTLE MENTAL MIX UP!

Last edited by zobernjik; 11-10-04 at 21:40. Reason: posted by mistake
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
Pingbacks are On
Refbacks are On