NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Assigning value to a cookie...?

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-26-2006, 09:57 PM THREAD STARTER               #1 (permalink)
New Member
Join Date: Aug 2006
Posts: 3
Smitch is an unknown quantity at this point
 



Assigning value to a cookie...?


Hey,

I was wondering if anyone could help me out with the following problem. I have created a user authentication system using dreamweaver. It all work fine except I want to make a few changes.

Here is the code I want to change;

Quote:
1 <Script runat="server">
????: NamePros.com http://www.namepros.com/programming/231882-assigning-value-to-a-cookie.html
2 Sub button_click(s as object, e as eventargs)
3 If ds_checkuserinfo.RecordCount = 1 Then
4 Response.Cookies("ckusername").Value = Request.Form("txtusername")
5 Response.Cookies("ckusername").Expires = DateTime.Now.AddDays(1)
6 Response.Redirect("index.aspx")
7 End if
8 End Sub
9 </script>
How do I assign the fist cookie, 'ckusername' (line 4) to a value from a MSSQL database instead of a form variable?

Thanks in advance
-Smitch
Smitch is offline  
Old 08-26-2006, 10:06 PM   #2 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




Code:
Response.Cookies("ckusername").Value = <?php echo $username_from_database; ?>
Barrucadu is offline  
Old 08-26-2006, 10:46 PM THREAD STARTER               #3 (permalink)
New Member
Join Date: Aug 2006
Posts: 3
Smitch is an unknown quantity at this point
 



sorry i should have said....needs to be asp.net. Sorry
Smitch is offline  
Old 08-26-2006, 10:46 PM   #4 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




Originally Posted by Smitch
sorry i should have said....needs to be asp.net. Sorry
I should really learn asp.net sometime..... lol
Barrucadu is offline  
Old 08-26-2006, 10:49 PM THREAD STARTER               #5 (permalink)
New Member
Join Date: Aug 2006
Posts: 3
Smitch is an unknown quantity at this point
 



any asp.net coders around? Im not sure how to actually get the value from that database and assign it to the cookie.

Thanks
Smitch is offline  
Old 08-26-2006, 11:15 PM   #6 (permalink)
Eating Pie
 
iNod's Avatar
Join Date: Nov 2004
Location: Canada
Posts: 2,272
iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of
 


Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
Hello,

-- Changed since I noticed you want .NET

Code:
SqlConnection conn = new SqlConnection(connectionString);
SqlCommand comm = new SqlCommand("SELECT fields FROM table_name", conn);
comm.Connection.Open();
SqlDataReader r = comm.ExecuteReader(CommandBehavior.CloseConnection);
Response.Cookies["TestCookie"].Value = r.GetString(0)
r.Close();
conn.Close();
I just did it off the top of my head.. So you can get an example. Though I am not a great ASP.Net coder..
????: NamePros.com http://www.namepros.com/showthread.php?t=231882

Good luck!

- Steve
__________________
I feel old.
Last edited by iNod; 08-26-2006 at 11:32 PM.
iNod is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 03:03 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger