Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys, ive got a problem here.. i want the text of the login page be post at the home page.
Example:
the username be on the home page..

what is the code plss.

my code in login page:
VB
If strUserURL <> "" Then
    lblInvalid.Text = ""
    FormsAuthentication.SetAuthCookie(txtUsername.Text, True)
    Response.Redirect("bob.aspx")


can i get the username using cookie??

thanks and more power
Posted
Updated 27-Apr-11 16:14pm
v2

Assign the username to a Session object once you SetAuthCookie and access it from the "bob.aspx"

After Authentication:
VB
Session("Username") = txtUsername.Text


In "bob.aspx":
VB
Dim username As String = Session("Username")



Mark it as answer if it is helpful
 
Share this answer
 
Session variable(Server side State Management) is more secure than cookies (client side State Management).
we can disable cookies, hack it or decode it.
Better to use Session variable.

Go through following link for State Management
StateManagement_Suggestions[^]


[Edit]Fixed typos and TXT words[/Edit]
 
Share this answer
 
v2
Comments
walterhevedeich 28-Apr-11 0:41am    
good advice. voted 5.
Why not use Session Variables? I personally believe that username is a sensitive data that must not be stored on the browser, unless your mechanism of clearing them is working well. Using session variables is much safer.
 
Share this answer
 
Comments
drkterror1 27-Apr-11 22:27pm    
Sir this is just for a localhost
i just want to post the username to anthoer form plss help
drkterror1 27-Apr-11 22:29pm    
another thing is i will make an expiration date to that cookie
Venkatesh Mookkan 28-Apr-11 0:02am    
I guess he is too amateur. May some code snippet would help him. ;)
walterhevedeich 28-Apr-11 0:08am    
I agree. voted 5 on your answer.
Venkatesh Mookkan 28-Apr-11 1:20am    
Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900