How to deal with Sessions in Google App Engine?
Solution 1:
Assuming you know about HttpSessions (if not it's simply cookie exchanged between sever and client in order to deal with the logged-in user).
So all user related or any other session-related information is stored in the server end and a session ID representing the information will be sent as cookie to the client, and the client will sent it back on every HTTP request.
AppEngine uses Datastore to store the session information and memcache for faster access to that information.
You can access the session data using a standard HttpSession object injected in every HTTP request.
The code to access this HttpSession varies in frameworks you use. If you want, I can specify code snippets to help to understand.
UPDATE:
If you are using servlets, then accessing session information will look like the following:
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final String userID = "Pankaj";
private final String password = "journaldev";
protected void doPost(HttpServletRequest request,
HttpServletResponse response) {
HttpSession session=request.getSession();
// access any value
User user = (User)session.getAttribute("loggedInUser");
}
And for Google Cloud endpoints, use the following:
@ApiMethod
public Response getUser( HttpServletRequest servletReq) {
HttpSession session = servletReq.getSession();
session.getAttribute("loggedInUser");
}