1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
//app/Controller/UserController.php
<?php
class UsersController extends AppController {
public function beforeFilter() {
$this->Auth->allow('index', 'view','add', 'logout');
}
public function login() {
if ($this->request->is('post')) {
debug($this->request->data);
if ($this->Auth->login()) {
//die('log');
debug($this->Session->read());
return $this->redirect($this->Auth->redirect());
} else {
//die('no log');
$this->Session->setFlash(__("Nom d'user ou mot de passe invalide, réessayer"));
}
}
}
public function logout() {
return $this->redirect($this->Auth->logout());
}
public function index() {
//$this->Session->write('test','testval');
//debug($this->Session->read());
session_start();
$_SESSION['coco']='cocoval';
echo $_SESSION['coco'];
debug($_SESSION);
session_destroy();
die();
//$this->User->recursive = 0;
//$this->set('users', $this->paginate());
}
public function view($id = null) {
$this->User->id = $id;
if (!$this->User->exists()) {
throw new NotFoundException(__('User invalide'));
}
$this->set('user', $this->User->read(null, $id));
}
public function add() {
if ($this->request->is('post')) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('L\'user a été sauvegardé'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('L\'user n\'a pas été sauvegardé. Merci de réessayer.'));
}
}
}
} |
Partager