Check for the existence of user id value in each and every page i.e
If you are storing that in session then check whether the value is in
session..
If session has null value redirect the page to login..
If this code is available in all the page of your application, that is
good in point of security..
Hope you are ending the session at the logout..