window.open() session loss problem solution

Recently, I want to realize the jump between the two projects to avoid the second login. There is a problem of window.open() session loss. Let me talk about the solution.

It was written like this at the beginning. Project A calls B's login request and returns success, that is, jumps to the corresponding page of project B. However, such an implementation writing method can only be effective when the two projects are in the same origin. Once cross-domain, the session cannot be passed, and it automatically jumps to the login page.

$.post("http://XXXX:8800/B/user!Login.action?user.userName="+userName+"&user.password="+passWord,function(data){
		if(data=='success'){
			window.open("/B/pages/index.jsp")
		}
	});
Modified as follows:
window.open("http://XXXX:8800/B/user!Login.action?user.userName="+userName+"&user.password="+passWord,'_blank');
B project background
public String Login() {
		ServletActionContext.getRequest().getSession().invalidate();
		ssoSuccess = userService.userLogin(user);
		return "ssoSuccess";
	}

Struts2 configuration:

<result type="redirect" name="ssoSuccess">/pages/index.jsp</result>
Using the redirection method, you can carry the session over.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324694697&siteId=291194637