java - Creating Guest Session -


is there way create guest session in aem?

our project e-commerce website built on aem , need track session of incoming guest , generate token out of it, in case there saving of items on cart. need track guest session/token in case user decides log in our site checkout items, back-end services can map on ownership of cart based on session/token.

by default if user not logged in , content viewed, aem internally logs user "anonymous", may consider guest.

you can value below:

 import org.apache.jackrabbit.api.security.user.authorizable;  import org.apache.jackrabbit.api.security.user.usermanager;  import org.apache.sling.api.resource.resourceresolver;  import javax.jcr.session;  ...  usermanager usermanager = resourceresolver.adaptto(usermanager.class);  session session = resourceresolver.adaptto(session.class);   // getting current user                          authorizable auth = usermanager.getauthorizable(session.getuserid());  log.info("\n--- user, principal="+auth.getid()+","+auth.getprincipal().getname());   // not try token if no user logged in - anonymous  if (auth.getid().equals(anonymous_user)) {      // write logic here          } else {      // user logged  } 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -