Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Assigning value to a cookie...?

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

Smitch

New Member
Impact
0
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;

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
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Code:
Response.Cookies("ckusername").Value = <?php echo $username_from_database; ?>
 
0
Close
sorry i should have said....needs to be asp.net. Sorry
 
0
Close
Smitch said:
sorry i should have said....needs to be asp.net. Sorry

I should really learn asp.net sometime..... lol
 
0
Close
any asp.net coders around? Im not sure how to actually get the value from that database and assign it to the cookie.

Thanks
 
0
Close
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
 
Last edited:
0
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Search: better matches first
Search now shows better matches first. Threads with your words in their title now come near the top. A poll with your words in its...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back