Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> My SessionHandler - problem z odczytem danych
404
post
Post #1





Grupa: Zarejestrowani
Postów: 226
Pomógł: 25
Dołączył: 22.05.2011

Ostrzeżenie: (0%)
-----


Witam!
  1. class MySessionHandler implements SessionHandlerInterface {
  2. public function open($save_path, $name) {
  3. //echo "SessionHandler::open<br />";
  4. return true;
  5. }
  6.  
  7. public function close() {
  8. //echo "SessionHandler::close<br />";
  9. return true;
  10. }
  11.  
  12. public function read($id) {
  13. echo "SessionHandler::read<br />";
  14. echo "id = $id<br />";
  15.  
  16. return ($data = DB::get_row('SELECT * FROM `session` WHERE `session_identifier` = ? LIMIT 1', array($id))) !== false ? serialize($data) : '';
  17. }
  18.  
  19. public function write($id, $data) {
  20. echo "SessionHandler::write<br />";
  21. $data = unserialize($data);
  22. if(($session = DB::get_row('SELECT * FROM `session` WHERE `session_identifier` = ?', array($id))) !== false) {
  23. echo 'update<br />';
  24.  
  25. return DB::update('session', array('session_update_time' => time()), 'session_identifier = \''. $id .'\'') !== false;
  26. } else {
  27. echo 'insert<br />';
  28.  
  29. $time = time();
  30. $session_data = array(
  31. 'session_identifier' => $id,
  32. 'session_start_time' => $time,
  33. 'session_update_time' => $time,
  34. 'user_id' => isset($data['user_id']) ? $data['user_id'] : SESSION_GUEST,
  35. 'user_data' => NULL,
  36. 'user_ip' => get_ip(),
  37. 'user_host' => get_host(),
  38. 'user_agent' => get_agent()
  39. );
  40. //return DB::insert(session', $session_data) !== false;
  41. }
  42.  
  43. return true;
  44. }
  45.  
  46. public function destroy($id) {
  47. echo "SessionHandler::destroy<br />";
  48.  
  49. return DB::query('DELETE FROM `session` WHERE `session_identifier` = ? LIMIT 1', array($id)) !== false;
  50. }
  51.  
  52. public function gc($max_lifetime) {
  53. echo "SessionHandler::gc<br />";
  54.  
  55. $time = time();
  56. return DB::query('DELETE FROM `session` WHERE (? - `session_update_time`) > ?', array($time, $time + $max_lifetime)) !== false;
  57. }
  58. }

Jakieś 6 godzin siedzę, patrzę w ten monitor i... nic. Czy naprawdę nie ma funkcji, która "przerobi" mi dane w metodzie SessionHandler::read na takie, które akceptuje sesja? Przy powyższym kodzie dane sesji po prostu przepadają ponieważ przy przekazaniu ich do $_SESSION wykryty zostaje niepoprawny format (tak podejrzewam). Przekopałem naprawdę dużo stron i jedyna sensowna metoda jaką znalazłem to napisanie własnego modułu i skompilowanie go z PHP ^^

Ten post edytował 404 13.09.2012, 22:04:33
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 22:57