Forum Moderators: coopster

Message Too Old, No Replies

How can I show last login details on homepage?

         

An156

3:44 pm on Mar 25, 2009 (gmt 0)

10+ Year Member



hey all!
i want to show the last login details when user login to the website.
can i do it through $_SESSION and storing the session time in database or do i need to create cookies? i dont have much knowledge abt the both. Please explain in detail.

Thanks in advance!

whoisgregg

6:03 pm on Mar 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could do it a lot of different ways. If you just want to show the last login, and don't want to log every attempt, you can just add a field to the user table called "lastlogin" and update it whenever they login. Right before you update it though, you can push the old value into the session.

If you wanted to log all attempts (perhaps worthwhile, depending on your security needs), then create a table called login_attempts and store every attempt. Then, to display the last login, you just do a select on that table with a LIMIT 1,1 to skip the current login.

I hope that's enough detail for you to get started on the code. If you run into trouble, just post back your code snippets and we'll take a look. :)

An156

6:17 pm on Mar 25, 2009 (gmt 0)

10+ Year Member



ya thanks gregg! will try your concept.