Through the code below I retrieve all users logged into the system and display them in a table.
<?php
$dados = array(
'session_id',
'ip_address',
'last_activity',
'user_data'
);
$this->db->select($dados);
$query = $this->db->get("ci_sessions");
?>
<tbody>
<?php foreach ($query->result() as $linha):?>
<tr>
<?php
$sessao = $linha->user_data;
$dados = unserialize($sessao);
?>
<?php if(!empty($dados['nome_usuario'])): ?>
<td><?php echo htmlspecialchars($dados['nome_usuario'],ENT_QUOTES, 'UTF-8');?></td>
<td><?php echo htmlspecialchars($linha->ip_address, ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo date('d/m/Y H:i:s',$linha->last_activity);?></td>
<td><a href="<?php echo site_url('login/deslogar'); ?>"
class="btn btn-danger btn-flat">
<?php echo lang('usuarios_deslogar_usuario'); ?></a></td>
<?php endif; ?>
</tr>
<?php endforeach;?>
</tbody>
What I want now is to have an option to drop user for each line displayed, which when clicked, the user is logged out.
Using the button:
<td>
<a href="<?php echo site_url('login/deslogar'); ?>"
class="btn btn-danger btn-flat"><?php echo 'Deslogar'; ?>
</a>
</td>
<?php endif; ?>
So how do I destroy only the session of id
that I logged off ?