[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 08-26-2006, 08:57 PM   #1 (permalink)
New Member
 
Join Date: Aug 2006
Posts: 3
0.00 NP$ (Donate)

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">
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, 09:06 PM   #2 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

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 online now  
Old 08-26-2006, 09:46 PM   #3 (permalink)
New Member
 
Join Date: Aug 2006
Posts: 3
0.00 NP$ (Donate)

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, 09:46 PM   #4 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

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


Quote:
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 online now  
Old 08-26-2006, 09:49 PM   #5 (permalink)
New Member
 
Join Date: Aug 2006
Posts: 3
0.00 NP$ (Donate)

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, 10:15 PM   #6 (permalink)
Eating Pie
 
iNod's Avatar
 
Join Date: Nov 2004
Location: Canada
Posts: 2,289
126.05 NP$ (Donate)

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..

Good luck!

- Steve
__________________
I feel old.

Last edited by iNod; 08-26-2006 at 10:32 PM.
iNod is offline  
Closed Thread


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

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


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 12:00 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85