Smutty

MVC Framework

View Code: Smutty_Controller_Session

Browse: All · Classes · Plugins

1
<?php
2
3
/**
4
* this class provides basic session handling functions
5
* that the user can extend so they don't have to write
6
* it themselves.
7
*
8
* NB: this does not provide any scaffolding, the user will
9
* need to write their own templates for this to work at
10
* the moment.
11
*
12
*/
13
15
16
/**
17
* handles the login action.
18
*
19
* @param Smutty_Data $data the data object
20
* @param Smutty_Session $session the session object
21
* @return nothing
22
*
23
*/
24
25
function loginAction( $data, $session ) {
26
27
$router = Smutty_Router::getInstance();
28
29
if ( $session->user )
30
if ( $url = $data->string('return_url') )
31
$this->redirectUrl( $url );
32
else
33
$this->redirect(array(
34
'controller' => $router->getDefaultControllerName()
35
));
36
37
$this->view();
38
39
}
40
41
/**
42
* handles the logout action.
43
*
44
* @param Smutty_Data $data the data object
45
* @param Smutty_Session $session the session object
46
* @return nothing
47
*
48
*/
49
50
function logoutAction( $data, $session ) {
51
52
$router = Smutty_Router::getInstance();
53
54
if ( $session->user )
55
session_destroy();
56
57
$this->redirect(array(
58
'controller' => $router->getDefaultControllerName()
59
));
60
61
}
62
63
}
64
65
?>

The code shown here is the code that is currently running this site. If you want to view the latest SVN version of the code then go to the Subversion repository.