This is a discussion on "Display logged in Username?" within the Classic ASP section. This forum, and the thread "Display logged in Username? are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Display logged in Username?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Display logged in Username?
i have a login page,
after the user successfully logged in to the page, they will go the main page. how can i retrieve the username and display them to the main page? i tried but, the what the page displayed is the first data in my database!! anyone help?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
|
|
|
|
|||
|
what you need to do is set up a session ID for the username. So when the user logs in Set what he entered to a session variable. Session("User") or something like that. Then when the user is logged in Response.Write(Session("User")) .
|
|
||||
|
Court Jester is right....
Often needed information such as username, preference data and anything about the 'login' that will be accessed frequently, could be stored in cookies, or session variables. There are however arguments for and against this method. What happens if cookies are turned off? Another option is to just hit the database once per page to retrieve that data. Hope this helps.
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
ok..in my login page i have this two text field called;
1.txtUsername 2.txtPassword I dont know how can i pass the txtUsername value to the session variable? Where shouls i set up the session variable? is it at the top of a page? Can you show me the sample coding for this?[txtUsername]
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
|
|
||||
|
First, when you process the form data containing the visitor's first name, write the name to a Session variable, as follows:
<% Session("FirstName") = Request.Form("fname") %> Next, add the following lines of code prior to the <HTML> tag at the top of each page in your site (except default.asp): <% If Session("FirstName") = "" Then Response.Redirect("default.asp") End If %> If the FirstName Session variable is blank, indicating that the visitor hasn't yet logged in, he'll be redirected to the default.asp page to do so. Regards, www.fjeldweb.com |
|
||||
|
The code abow is for secure login, so that the users needs to go from your login page and not just type in the url.
So to show the login name, just type: Welcome <%=Session("FirstName")%> to my page! Regards, www.fjeldweb.com |
![]() |
| Tags |
| display, logged, username |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| input $_SESSION['username'] = $username; on login page help | Aaron1988 | PHP Forum | 2 | Jan 28th, 2008 14:14 |
| [SOLVED] Dispaly User Data Once Logged In | longstand | PHP Forum | 2 | Nov 21st, 2007 20:16 |
| users logged in script | csun | PHP Forum | 4 | May 8th, 2007 12:05 |
| online image and offline image showing when logged in and logged out | Aaron1988 | PHP Forum | 4 | Apr 5th, 2007 17:24 |
| When logged in options | Aaron1988 | Webforumz Cafe | 36 | Nov 27th, 2006 15:45 |