(セッション)

Description

How Plone handles anonymous and logged in user sessions. How to store and retrieve session data variables programmatically.

はじめに

Sessions are visitor sessions at the site.

Sessions have features life

  • Login and logout, but also identified by a cookie
  • Timeout
  • Hold arbitary per-user data on server side
  • Identified by cookies

In Plone, sessions are managed by Zope’s session_data_manager tool. The source code is in Products.Sessions.

セッションパラメーターの設定

Plone has a tool called session_data_manager.

Example:

sdm = self.context.session_data_manager
session = sdm.getSessionData(create=True)
session.set("my_option", any_python_object_supporting_pickling)

セッションを取得する

Plone has a convenience method to get the session of the current user:

session = sdm.getSessionData(create=True)

セッション id を取得する

Each session has unique id associated with it, this concerns both anonymous and logged-in users.

Session is based on browser cookies, so it is browser specific. If the same user has multiple browsers open on your site, all browsers have their own session.

If you need to refer to the session id, you can query for it:

sdm = self.context.session_data_manager
session_id = sdm.getBrowserIdManager().getBrowserId(create=False)
# Session id will be None if the session has not been created yet

目次

前のトピックへ

セッションとクッキー

次のトピックへ

(クッキー)

このページ