Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2.  
  3. class Custom_Session extends Hm_Memcached_Session {
  4.  
  5. /**
  6. * check for an active session or an attempt to start one
  7. * @param object $request request object
  8. * @return bool
  9. */
  10. public function check($request, $user=false, $pass=false, $fingerprint=true) {
  11.  
  12. /* active session */
  13. if (array_key_exists($this->cname, $request->cookie)) {
  14. $this->get_key($request);
  15. $this->start($request, true);
  16. }
  17.  
  18. /* no active session, check for login state */
  19. if (!$this->is_active()) {
  20.  
  21. /* use whatever code you need to determine if a user is logged in,
  22. * and get there username, if they should be logged into cypht,
  23. * do the following:
  24. */
  25. $this->start($request);
  26. $this->set('username', $your_user_name);
  27. }
  28.  
  29. /* active session but logged out of your app, so log out of cypht */
  30. else {
  31. /* check to see if a user is logged OUT of your app, and if so
  32. * call the following
  33. */
  34. $this->destroy($request);
  35. }
  36. }
  37. }
  38.  
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement