Liferay is a Gartner Magic Quadrant Leader for the Sixth Year! Find out why

Combination View Flat View Tree View
Threads [ Previous | Next ]
Givika valluri
User Longin Date and Time.
June 2, 2012 10:57 PM
Answer

Givika valluri

Rank: Junior Member

Posts: 49

Join Date: March 29, 2012

Recent Posts

Hi Everyone,

i need some help

If different different users Login they can see their Last Login Date an Time .

For instance :

if user login the page yesterday and he will login today again,then he can see his last login date and time when he will be entered.means Last login 02nd june,6:30pm.

in this same way i want,

Thanks in advance
Hitoshi Ozawa
RE: User Longin Date and Time.
June 3, 2012 6:06 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

This is possible because there is a "lastLoginDate" in User_ table in the database.

User user = UserLocalServiceUtil.getUser(userId);
Date lastLoginDate = user.getLastLoginDate();
Givika valluri
RE: User Longin Date and Time.
June 3, 2012 9:34 PM
Answer

Givika valluri

Rank: Junior Member

Posts: 49

Join Date: March 29, 2012

Recent Posts

Hi Hitoshi,

Thanks a lot to reply,


Can you Please explain briefly i am not getting.


Thanks in Advance
Tejas Kanani
RE: User Longin Date and Time.
June 4, 2012 1:11 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Hi Givika,

This is possible because there is a "lastLoginDate" in User_ table in the database.


As Hitoshi has mentioned, Liferay is storing last login date of each user in database. So that when any user logs in Liferay is storing that date and time of log in. So that next time you login, you'll still have last login date stored in DB.

And to get that date, use below suggested code by Hitoshi.

1
2User user = UserLocalServiceUtil.getUser(userId);
3Date lastLoginDate = user.getLastLoginDate();


I hope this will be helpful for your understanding.

Thanks,
TK
Givika valluri
RE: User Longin Date and Time.
June 4, 2012 5:42 AM
Answer

Givika valluri

Rank: Junior Member

Posts: 49

Join Date: March 29, 2012

Recent Posts

Hi Tejas,

Where to use i am not understanding. Can You Please help me to use where i can use.


Thanks in Advance,
Givika valluri
RE: User Longin Date and Time.
June 5, 2012 9:33 AM
Answer

Givika valluri

Rank: Junior Member

Posts: 49

Join Date: March 29, 2012

Recent Posts

Hi guys ,


Please help me to display LastLoginDate of user.

Please its Urgent
Tejas Kanani
RE: User Longin Date and Time.
June 5, 2012 10:39 PM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

What is your exact requirement, where you want to display last login date ? theme? users account page ? Where exactly ?
And what problem are you facing right now ? As you have code ready to display last login date on earlier reply by Hitoshi.
Givika valluri
RE: User Longin Date and Time.
June 15, 2012 10:27 AM
Answer

Givika valluri

Rank: Junior Member

Posts: 49

Join Date: March 29, 2012

Recent Posts

Hi Tejas,

I want to display Last Login date in User Account Page.


Thanks in Advance.
Tejas Kanani
RE: User Longin Date and Time.
June 17, 2012 10:29 PM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Which version of Liferay are you using ?
Givika valluri
RE: User Longin Date and Time.
June 17, 2012 11:33 PM
Answer

Givika valluri

Rank: Junior Member

Posts: 49

Join Date: March 29, 2012

Recent Posts

Hi Tejas,


Liferay 6.0 im using
Ajeykumar Hulivana Boregowda
RE: User Longin Date and Time.
June 17, 2012 11:42 PM
Answer

Ajeykumar Hulivana Boregowda

Rank: Junior Member

Posts: 72

Join Date: March 12, 2012

Recent Posts

Hi Givika,

Create a portlet that contain following code in its view page, and place this portlet in the page wr u want........

<%
ThemeDisplay themeDisplay =
(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
User usr=null;Date lastLoginDate=null;
if(themeDisplay.isSignedIn())
{
usr=themeDisplay.getUser();
lastLoginDate = usr.getLastLoginDate();
%>
<%=lastLodinDate%>

I think it may help you......

Thaks
Ajey
Praveen P
RE: User Longin Date and Time.
June 17, 2012 11:59 PM
Answer

Praveen P

Rank: Regular Member

Posts: 100

Join Date: February 20, 2012

Recent Posts

create one portlet and use that code in view.jsp you will get last log in date and time, but some jar file and tld are needed ask hitoshi what jar's and tld are required, thats all
because as hitoshi told in user_ table, last log in date is there just you need to access and u need to print it
Tejas Kanani
RE: User Longin Date and Time.
June 18, 2012 12:05 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Hi Givika,

I want to display Last Login date in User Account Page.


If you need to display last login date in User Account Page then you need to modify Liferay OOTB code. And to modify Liferay OOTB jsp code, you must use hooks. Using hooks you just need to add suggested code by Ajeykumar in particular jsp.

So first find out which jsp you need to modify and create hook for the same. For more detail regarding how to use hook to override OOTB jsp visit this link.

I hope this will be helpful.

Thanks,
TK