public static final String visitorCookieName = "OFBiz.Visitor";
public static void setUserLogin(HttpSession session, GenericValue userLogin, boolean userCreated) {
if (userLogin == null) return;
ModelEntity modelUserLogin = userLogin.getModelEntity();
GenericValue visitor = (GenericValue) session.getAttribute("visitor");
if (visitor != null) {
visitor.set("userLoginId", userLogin.get("userLoginId"));
if (modelUserLogin.isField("partyId")) {
visitor.set("partyId", userLogin.get("partyId"));
}
try {
visitor.store();
} catch (GenericEntityException e) {
Debug.logError(e, "Could not update visitor: ", module);
}
}
GenericValue visit = getVisit(session);
if (visit != null) {
visit.set("userLoginId", userLogin.get("userLoginId"));
if (modelUserLogin.isField("partyId")) {
visit.set("partyId", userLogin.get("partyId"));
}
visit.set("userCreated", Boolean.valueOf(userCreated));
// make sure the visitorId is still in place