Create session dynamically using java action call

0
I am having a custom login page , I am using anonymous user, checking the credentials and showing them the home, What i need is I have to create session for the user who is logging in, I have to do that using java action call, I dont want to use authentication login widget and java script to create session, , please any one share the java code to create a session for account, What is the problem in my code? Is any import needs to be done? . Thanks in advance!
asked
1 answers
1

Hey Rishi, 

 Try using this code for custom login functionality using JAVA action. 

Note: You need to pass System.User as Input parameter to this Java Action to work. 

        IMxRuntimeResponse response= this.getContext().getRuntimeResponse().get();

        IContext systemContext = Core.createSystemContext();

        ISession newSession = Core.initializeSession(Core.getUser(systemContext, user.getName()), ""); 

        // the user.getName here used is the name of the object passed as input parameter 
        response.addCookie("XASSESSIONID", newSession.getId().toString(),"/" ,"" ,-1 );
        response.addCookie("XASID", "0." + Core.getXASId(),"/" ,"" ,-1);
        

answered