After spending 2 sleepless nights i got the answer, but not sure whether its the correct way or not. I want to sum it up here.
So what i did is I wrote a method where i checked for the logout time for that username, if the logout time is not null the n allow, i.e identity.login() else return back.
Now while logging out we were able to catch the time stamp and persist it in the user table, but if session time out occurs, then we were not able to do this. So in order to achieve this i wrote one ServletContextListener, in which i wrote one method with @Observer(
org.jboss.seam.preDestroyContext.SESSION). So it solved the problem of em is null and no transaction errors. And I am able to persist successfully at the session time out.
All the best