Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7517f18

Browse files
Se agrega cerrar sesion en main
1 parent 25a0939 commit 7517f18

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

‎app/controllers/Main/MainController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function __construct()
1515
{
1616
$this->session = new Session();
1717
$this->session->init();
18-
if($this->session->getStatus() === 1 || !$this->session->get('email'))
18+
if($this->session->getStatus() === 1 || empty($this->session->get('email')))
1919
exit('Acceso denegado');
2020
}
2121

@@ -25,4 +25,10 @@ public function exec()
2525
$this->render(__CLASS__, $params);
2626
}
2727

28+
public function logout()
29+
{
30+
$this->session->close();
31+
header('location: /php-mvc/login');
32+
}
33+
2834
}

‎app/views/Main/main.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!DOCTYPE html>
33
<html>
44
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
57
<title>Home</title>
68
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
79
</head>
@@ -10,7 +12,8 @@
1012
<div class="jumbotron">
1113
<div class="container text-center">
1214
<h1>Sesión iniciada</h1>
13-
<h3><?= $email ?></h3>
15+
<h3><?= $email ?></h3>
16+
<a href="/php-mvc/main/logout">Cerrar sesión</a>
1417
</div>
1518
</div>
1619
</body>

‎system/libs/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function add($key, $value)
2929
*/
3030
public function get($key)
3131
{
32-
return $_SESSION[$key];
32+
return !empty($_SESSION[$key]) ? $_SESSION[$key] : null;
3333
}
3434

3535
/**

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /