サーバー側であるPHPまたは他の言語は、クライアントマシンにセッションをどのように保存しますか?
手伝ってくれませんか?
Sessions are stored on the server. Either on the file system (often inside the tmp folder) or inside a database (if database session handling has been setup). Sometimes, they'll be stored in a caching daemon such as Memcached. Either way, session data is stored on the server and not on the client's machine.
On the client's side, you'll typically have a cookie, which contains the session ID that is used to link the user to the session data that is stored on the server. In certain circumstances, this ID may be forcefully appended to the URL, which is why you'll sometimes come across websites with PHPSESSID as a GET parameter in their URL.
Basically, when you visit a website, that site will read the PHPSESSID that is stored inside the cookie that is on your machine. It then uses that ID to find the session data that is relevant to your visit.
PHP stores a cookie in the user's browser. That cookies doesn't store any session data, it just uniquely identifies the user. The session data is stored on the server, and associated with the user's cookie.
So when a user makes a request, their session ID stored in the cookie is passed along with the request. The server can use that session ID to retrieve the actual session data and make it available to the PHP script.
実際には、サーバーに基づくファイルです。session_start() を呼び出すと、PHP はサーバーの HDD にファイルを作成し、そのセッションで隠したものをすべて格納します。クライアント側では、そのファイルに対応するランダムな文字列を含む Cookie (デフォルトでは PHPSESSID と呼ばれます) を取得します。次に、PHP はランダム ガベージ コレクションを使用して、古いセッション ファイルを削除します。セッションを php.ini のタイムアウトよりも長く持続させたい場合は、独自のセッション ハンドラーを作成して、memcached やデータベースなどの内部にセッションを保存することができます。
関連するPHP Webサイトのセクションは次のとおりです http://www.php.net/manual/en/session.configuration.php
はい - 「セッション [データが保存されている] クライアント マシン」の可能性があります。
通常、セッション データはサーバー側に保存されますが (通常は Cookie の形式でクライアントから提供される識別子を使用)、同じセマンティクスを実現するためにセッション データをサーバー側に保存する必要がある理由はありません1。
セッション プロバイダーは、すべてのセッション データを Cookie に直接保存できます。これは、すべてのセッション データをクライアント側に保存できることを意味します。そして、そのようなプロバイダーがあります。
ただし、Cookie ストレージを「安全に」使用するには、はるかに多くの作業が必要です。つまり、暗号化と MAC は必要最小限の追加です。( Cookie へのセッション データの保存: 注意すべき問題とセキュリティ上の問題を参照してください。)
1セッション データの実質的な唯一の「要件」は、ブラウザ セッション内で、すべてのウィンドウ/タブが同じセッション データを共有する (共有できる) ことです。Cookie は、いくつかのルールに従って HTTP リクエストごとに送信されるため、これを行う最も簡単な方法です。