.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 8th, 2005, 04:52 AM
tallpaul101 tallpaul101 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 33 tallpaul101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 26 m 17 sec
Reputation Power: 4
BC30311: Value of type 'System.Web.HttpCookie' cannot be converted to 'String'.

Hi there

I am using forms authentication to restrict access to certain pages. The user is redirected to the login screen.

The login screen uses the following code to create a cookie called UserId

Code:
if dtrResults.Read() 

System.Web.Security.FormsAuthentication.SetAuthCoo  kie(Userid, True)
	Response.Redirect("createanad.aspx")
	else    


What i need to do now is read this cookie and use the Userid from it to insert in to a database so the adverts created are associated with that user.

Can anyone help me to read back the contents of the cookie and assign to a variable so i can insert it into the database

This is what i have so far but it throws the above error in the subject

Dim strULogin as string = Cstr(Request.Cookies("userid"))

I am already checking to see if the user is authenticated at the top of the page and this seems to work. Just need to pass this value to my dataabse

Any help would be great
Paul

Reply With Quote
  #2  
Old November 8th, 2005, 05:56 AM
tallpaul101 tallpaul101 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 33 tallpaul101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 26 m 17 sec
Reputation Power: 4
just realised....Please help

that allthough i am setting a cookie i am not inserting any particular values in it. I think that is called subkeys

I am trying to put the userid from my users table in the cookie. When when the user creates an advert the userid from this cokkie is inserted in the adverts table.

Make sense

Anyone no the systax for geeting a value from a database and inserting it into a cookie

Here is my code

Code:
Dim DBConn as OleDbConnection    
	Dim dtrResults as OleDBDataReader    
 	Dim DSLogin as New DataSet 
	DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" & "DATA SOURCE=" & Server.MapPath("data/Class.mdb;"))  
	DBConn.Open()      
 	Dim CmdStr As String
	Dim UseriD As String
  	Dim DBSelect As New OleDbCommand      
	CmdStr =("Select eMail, pass, UserID from tblUsers Where eMail =” & “@Email and pass = @Pass ")      
  	DBSelect = new OleDbCommand(CmdStr, DBconn) 

	DBSelect.Parameters.Add("@email", OleDbType.VarChar, 255) 
	DBSelect.Parameters.Add("@Pass", OleDbType.VarChar, 255)
	DBSelect.Parameters("@email").Value = txtEmail.text 
	DBSelect.Parameters("@Pass").Value = txtPass.text
	dtrResults = DBSelect.ExecuteReader() 
	if dtrResults.Read() 

	 System.Web.Security.FormsAuthentication.SetAuthCoo  kie(Userid, True)
	
	Response.Redirect("createanad.aspx")
	

	else         
  lblmessage.text = "Sorry your eMail or password do not match our records.  If you have forgotten your password <a href='ForgottenPassword.aspx'>click here</a>" 

	end if
	end sub


Cheers for any help--please help

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > BC30311: Value of type 'System.Web.HttpCookie' cannot be converted to 'String'.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT