We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

tylerhall on 12/31/69


Tagged

wrapper class session


Versions (?)


Who likes this?

9 people have marked this snippet as a favorite

luman
Bunker
katxorro70
jkochis
jackol
vali29
bioascii
huze
romanos


PHP Session Wrapper Class


Published in: PHP 


  1. class Session
  2. {
  3. function Session()
  4. {
  5. }
  6.  
  7. function set($name, $value)
  8. {
  9. $_SESSION[$name] = $value;
  10. }
  11.  
  12. function get($name)
  13. {
  14. if(isset($_SESSION[$name]))
  15. return $_SESSION[$name];
  16. else
  17. return false;
  18. }
  19.  
  20. function del($name)
  21. {
  22. unset($_SESSION[$name]);
  23. }
  24.  
  25. function destroy()
  26. {
  27. $_SESSION = array();
  28. }
  29.  
  30. function save_prefs()
  31. {
  32. global $db, $auth;
  33. $prefs = serialize($this->prefs);
  34. $db->query("UPDATE condra_users SET prefs = '$prefs' WHERE id = '{$auth->id}'");
  35. }
  36. }

Report this snippet 

You need to login to post a comment.