Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class RememberMeComponent extends Object{
- var $components = array('Auth', 'Cookie');
- var $controller = null;
- var $period = '+2 weeks';
- var $cookieName = 'User';
- function startup(&$controller){
- $this->controller =& $controller;
- }
- function remember($username=null, $password=null){
- $cookie = array();
- $cookie['email'] = $username;
- $cookie['password'] = $password;
- $this->Cookie->write($this->cookieName, $cookie, true, $this->period);
- }
- function check(){
- $cookie = $this->Cookie->read($this->cookieName);
- if (!is_array($cookie) || $this->Auth->user())
- return;
- if ($this->Auth->login($cookie)){
- $this->Cookie->write($this->cookieName, $cookie, true, $this->period);
- }else{
- $this->delete();
- }
- }
- function delete(){
- $this->Cookie->delete($this->cookieName);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement