Hope this is helpful to those who happen to encounter this problem. The following is the source code of asp.net, which can be downloaded.
window.open opens the window Session is lost
Although window.open is very unpleasant, it sometimes has certain uses. Nowadays, many office automation systems (OA),
In order to give the user more space for operation, window.open is used to open a window with only the title bar after the user logs in.
But in the window that opens, the session generated in the login window cannot be found.
1: Solution in asp.net:
1: If the login window is default.aspx, we can write this in the background:
In this way, we can pass the SessionID to the newly opened window index.aspx, and we can use this SessionID in index.aspx
Reconstruct a Session.
2: In index.aspx we can reconstruct the session like this:
Among them, we use the SessionIDManager class under the SessionState namespace, and we override its CreateSessionID
This virtual method is used to retrieve or retrieve the Session. The virtual method CreateSessionID needs to be rewritten, and it returns a new Session
’s SessionID, and this SessionID is passed from the login interface default.aspx, so we can think of the newly constructed
Session and the Session of the login window are one Session.
2: Solution in php:
1: The same method is used to solve this session loss in php, and it is simpler. It only requires two functions.
The session_id function is to obtain the SessionID of the login interface.
2: Then we can construct a Session based on this SessionID just like in .net:
session_id($sid);
session_start();
The function Session_id is to reconstruct the Session.