Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.1

Request #7578 Serialization and Cookie Manager
Submitted: 2006-05-08 15:36 UTC
From: jausions Assigned: avb
Status: Closed Package: HTTP_Client (version 1.0.0)
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2006-05-08 15:36 UTC] jausions (Philippe Jausions)
Description: ------------ I plan on using HTTP_Client with the cookie manager, but I also'd like to serialize and store the cookies between script call. Below is the __wakeup() method I've added to the HTTP_Client_CookieManager class to clean up expired cookies. However given how the current code is organized, to serialize the cookie manager, I'd need to serialize the whole HTTP_Client. I need a way to assign and retrieve the cookie manager object used in the HTTP_Client. How do you suggest that be accomplished? I don't mind writing the code, I just need to know what you'd like to see so I don't waste my time writing an implementation that wouldn't be satisfactory I'm thinking about either adding 2 methods setCookieManager() and &getCookieManager() or turning the $_cookieManager property into a public $cookieManager one (but that could be a problem of BC break for people that have already extended the HTTP_Client class.) Let me know, -Philippe Test script: --------------- Added to HTTP_Client_CookieManager class: <?php /** * Cleans up expired cookies during unserialization */ function __wakeup() { foreach ($this->_cookies as $hash => $cookie) { if (isset($cookie['expires']) && strtotime($cookie['expires']) < time()) { unset($this->_cookies[$hash]); } } } ?>

Comments

 [2006-06-02 20:15 UTC] avb (Alexey Borzov)
Added __sleep() and __wakeup() magic methods to CookieManager(), the former clears all session cookies, the latter clears expired cookies (as in your implementation). Added getCookieManager() to HTTP_Client class and added a third parameter ($cookieManager) to its constructor.