저는 영감을 얻어 saaj가 작동하는 해결책을 발견했습니다. 사용해보기 ...
import cherrypy.lib
config = {
'global' : {
'server.socket_host' : '127.0.0.1',
'server.socket_port' : 8080,
'server.thread_pool' : 4,
'tools.sessions.on': True,
'tools.sessions.storage_type': "file",
'tools.sessions.storage_path': "adf"
}
}
class Helloworld:
@cherrypy.expose
def make(self, token=''):
'''You can try open it from another browser
once set the value in /counter
'''
if(token == ''):
cherrypy.lib.sessions.init()
# take this token and put in the url 127.0.0.1:8080/make/ + token
return cherrypy.session.id
else:
#send two requests with the token. 1. to set a session var
# and 2. to retrieve the var from session
cherrypy.lib.sessions.init(self, id=token)
print('do something')
# on the second request check the value after init and it's HI!
cherrypy.session['something'] = 'HI'
return token
if __name__ == '__main__':
cherrypy.quickstart(Helloworld(), '/', config)
희망이 있습니다.
그는 요청이 브라우저에서 오지 않았으며 쿠키를 사용하여 세션 ID를 저장할 수 없다고 언급했습니다. –
안녕하세요, 저는 쿠키 [ 'session_id'] = 토큰을 설정하고 init()을 호출하는 데 중점을 둡니다. 테스트 후 작동하지 않았고 기존 세션 내용을 다시 검색 할 수 없습니다. 추신. 토큰을 테스트하기 위해 curl과 HTTP GET을 사용하고 있습니다. – Takol
@AndrewKloos 코드가 클라이언트 기능과 관련이없는 가짜 요청 쿠키이기 때문에 귀하의 의견은 관련이 없습니다. – saaj