ユーザーが自分のアカウントに登録してアクセスできる Web サイトを開発しています。ユーザーが接続すると、シリアル化と base64 エンコーディングを使用して User オブジェクトを Cookie に保存します。それは完全に機能していましたが、突然 PHP スクリプトが Cookie を作成しなくなりました。私のPHPスクリプトは次のとおりです。
/**
* Function that creates a cookie from an User object
* @param User $user User object to be stored in the cookie
* @param int $timeout Lifetime of the cookie (0 if should be destroyed when the navigator is closed)
*/
function setUserCookie($user, $timeout = COOKIE_MAXLIFETIME) {
setcookie('user', base64_encode(serialize($user)), $timeout, '/');
}
問題がどこから来ているのかわかりません。誰かが私を助けてくれることを願っています:)
編集 : これは大学向けのプロジェクトです。Cookie にオブジェクトを保存しているときに Web サイトが脆弱になる可能性があることは承知していますが、Web サイトのセキュリティよりも機能に重点を置く必要があります。