@Override
	public void afterPhase(PhaseEvent event) {
		// TODO Auto-generated method stub
		System.out.println("Inside phase listner");

		FacesContext facesContext = event.getFacesContext();
		String currentUser = facesContext.getViewRoot().getViewId();
		boolean isLoginPage = (currentUser.lastIndexOf("index.jsp") > -1);
		HttpSession session = (HttpSession) facesContext.getExternalContext()
				.getSession(false);

		if (session == null) {
			System.out.println("session is null");
			NavigationHandler nh = facesContext.getApplication()
					.getNavigationHandler();
			nh.handleNavigation(facesContext, null, "index");
		}
		if (!isLoginPage && (currentUser == null || currentUser == "")) {
			{
				String userId = (String) session.getAttribute("username");
				if (userId == null) {
					System.out.println("session is null");
					NavigationHandler nh = facesContext.getApplication()
							.getNavigationHandler();
					nh.handleNavigation(facesContext, null, "index");
				}
			}
		}

	}