I will answer myself because I got the solution.
The session expires after 16 hours. If you develop middleware
which has to keep the state, check the 'status' code after each
request sent to connect xml api. If the status is "no-access" then
the session has been expired. Just login your application again and
redo the request. that's it.