Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 10th, 2008, 08:04 PM
Member
 
Join Date: Feb 2008
Posts: 75
Default Last Login time stamp on login using Dreamweaver

Greetings,

I have an ASP page that contains a form (form_login) with a Log In User server behavior. I used Dreamweaver CS3 to design the page. What I want to do upon a user's log in is to populate a date stamp in a field (LastLogin) within the user authentication table.

I know how to use hidden fields to write a date stamp to a field on an Update Record or Insert Record form, but I'm not sure how to accomplish the same in this scenario when the form submission doesn't submit to or update a table.

Any advice or resources anyone may have would be most appreciated.

Regards,

JM
Reply
  #2  
Old September 10th, 2008, 09:34 PM
codegecko's Avatar
Moderator
 
Join Date: May 2007
Location: United Kingdom
Age: 21
Posts: 341
Default

Hi there,

You need to create a bit of code that says: "If the user has authenticated themselves correctly, then UPDATE this date field to show the last time they logged in (i.e. now)", does that sound about right?

Basically, you'd do something like this:
Expand|Select|Wrap|Line Numbers
  1. If blUserIsAuthenticated = True Then
  2.    Dim rsLoggedIn = Server.CreateObject("ADODB.Recordset")
  3.    Dim sqlLoggedIn = "UPDATE tbl_Users SET LastLoggedIn = NOW() WHERE Username = '" & strUsername & "'"
  4.    rsLoggedIn.Open sqlLoggedIn, objConn, 2, 3
  5.    'Then pass them to another page or whatever your app is doing.
  6. Else
  7.    'Kick user
  8. End If
  9.  
This is assuming you have already created a connection object (objConn) to connect to your database and log your user in.

The principle is simple - set LastLoggedIn field to NOW() (SQL recognises this as the current date and time) where the username is equal to the username that has successfully logged in.

OR: If you're using inline SQL to log your user in (I hope you are using stored procedures!), then when you've created your recordset object, do this:

Expand|Select|Wrap|Line Numbers
  1. If blUserIsAuthenticated = True Then
  2.    rsUser!LastLoggedIn = Now()
  3.    rsUser.Update
  4. End If
  5.  
Hope this helps.

medicineworker
Reply
  #3  
Old September 11th, 2008, 11:16 PM
Member
 
Join Date: Feb 2008
Posts: 75
Default

I understand the concept of what you're talking about. Let me see if I can implement it. I'll post back if I have any issues (which I usually do).

Regards,

JM
Reply
Reply

Bookmarks

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 Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles