M
M
MrlCrosl2014-12-30 19:51:21
Java
MrlCrosl, 2014-12-30 19:51:21

How to save session after POST request in java?

Good afternoon. Implemented authorization on the Steam website using Java. On successful login, I get the following response:

{"success":true,"login_complete":true,"transfer_url":"https:\/\/store.steampowered.com\/\/login\/transfer","transfer_parameters":{"steamid":"***","token":"***","remember_login":false,"webcookie":"***"}}

Now I don’t know how to save the session so that you can receive any information while being authorized?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanKiLL, 2014-12-30
@MrlCrosl

HttpSession session = request.getSession();
session.setAttribute("key", "value"); // положить в сессию что то

Take from the session by key what you put into it session.getAttribute(key);
request.getSession();Creates a session if there is none or returns an existing one.
request.getSession(true);Returns the existing session or null if there is none.
session.setMaxInactiveInterval(30*60);you can set how long the session will live in this case 30min.
When creating a session, a new cookie will be added with the name JSESSIONIDwhere the session id is stored
Get the session id from the code - session.getId();
Destroy the session by hand - session.invalidate();
Read the docs onHttpSession

Y
Yuri Shikanov, 2014-12-30
@dizballanze

Cookies should be set, in theory (see the Set-Cookie response header), respectively, you need to add to the header (Cookie: ...) for the following requests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question