Advertisement
lamhottt

Controller-Login

Aug 11th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1.  
  2. use System\GF_Router;
  3.  
  4.  
  5. /*
  6. * Contoh menggunakan Controller
  7. * Gunakan halaman controller ini untuk membuat session dan cookie user
  8. * dan selalu gunakan extends GF_Router
  9. */
  10. class User_Controller extends GF_Router
  11. {
  12.    
  13.     function __construct()
  14.     {
  15.         echo "Constructor Run... <hr>";
  16.     }
  17.  
  18.     public function login()
  19.     {
  20.         /**
  21.          * Contoh membuat session
  22.          * self::newSession("KEY","VALUE");
  23.          */
  24.         self::newSession("id_user",1);
  25.         self::newSession("username","Admin");
  26.         echo "Session Berhasil Dibuat";
  27.     }
  28.     public function getSessionUser()
  29.     {
  30.         /**
  31.          * Contoh mendapatkan session user
  32.          * self::getSession("KEY");
  33.          */
  34.         return self::getSession("username-gf-pro");
  35.     }
  36.  
  37.     public function userView()
  38.     {
  39.         /**
  40.          * Do something amazing here...
  41.          */
  42.         self::setView("userpage");
  43.     }
  44.  
  45.     public function logout()
  46.     {
  47.         /**
  48.          * Do something amazing here...
  49.          */
  50.         self::destroySession("id_user");
  51.         self::destroySession("username");
  52.         echo "User Logout";
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement