Display logged in Username?

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 23rd, 2004, 03:29
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
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)

  #2 (permalink)  
Old Aug 23rd, 2004, 05:05
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
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")) .
  #3 (permalink)  
Old Aug 23rd, 2004, 13:05
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
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
  #4 (permalink)  
Old Aug 24th, 2004, 02:25
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
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)
  #5 (permalink)  
Old Jan 14th, 2005, 13:35
Anonymous User
Guest
Posts: n/a
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
  #6 (permalink)  
Old Jan 14th, 2005, 13:38
Anonymous User
Guest
Posts: n/a
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
Closed Thread

Tags
display, logged, username

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

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


All times are GMT. The time now is 15:43.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

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