0
I am creating a small site, but when I press to exit, the site depresses, but if I put the link of one of the pages, I can enter the system and not check if the login was done, even with security fields
Login.php:
<div class="login">
<div class="row">
<div class="col-sm-5 texto-capa">
<form method="POST" action="validalogin.php">
<img class="mb-4" src="imagens/icon/android-icon-72x72.png" alt="" width="72" height="72">
<h3>Área de Login</h3>
<div class="form-group">
<label>E-mail</label>
<input type="text" class="form-control" id="login" name="login" placeholder="Digite seu e-mail..." />
</div>
<div class="form-group">
<label>Senha</label>
<input type="password" class="form-control" id="senha" name="senha" placeholder="Digite sua senha..."/>
</div>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Relembre-me
</label>
</div>
<button type="submit" class="btn btn-entrar"><b>ENTRAR</b></button><br>
<p class="mt-5 mb-3 text-muted">© 2018</p>
</form>
<p class="text-center text-danger">
<?php
if(isset($_SESSION['security'])){
echo $_SESSION['security'];
unset($_SESSION['security']);
}
?>
</p>
</div>
</div>
</div>
Security.php
<?php
ob_start();
if($_SESSION['login'] == null || $_SESSION['id'] == null){
$_SESSION['security'] = "Efetue o Login!";
header("Location: login.php");
}
?>
Close.php
<?php
unset($_SESSION['login'], $_SESSION['id'], $_SESSION['usuario']);
session_destroy();
header("Location: login.php");
?>
Forehead changing the
== null
for== ""
(empty string)– Costamilam
I tried, but it didn’t work :/
– Gabriel Henrique
Forehead
isset($_SESSION ["nome"])
, if it doesn’t make aecho
of the session variable and put to the question– Costamilam
Unfortunately it didn’t even work echo
– Gabriel Henrique
Checks that the session has been started on all pages (
session_start ()
), try to changeob_start
forsession_start
, if I’m not mistaken to use the ob also need to useob_end_flush()
– Costamilam
In all, can post an example that works and does not save the security of the site ?
– Gabriel Henrique
As far as I know to be able to manipulate the session variable it is necessary to call the function
session_start();
before any other php code (<?php session_start(); ...
, about the safety of this I can no longer say– Costamilam