function sys_session_create($userId, $force = FALSE) { if (!sys_session_test() || $force) { if (!empty($userId)) { $sessionId = md5(uniqid(mt_rand(), true)); $_SESSION["sessionId"] = $sessionId; $_SESSION["userId"] = $userId; return $sessionId; } } return ""; }
function sys_session_create($conexion, $force = FALSE) { if (!sys_session_test() || $force) { $userId = $_SESSION['userId']; if (!empty($userId)) { $sessionId = md5(uniqid(mt_rand(), true)); $hashedSessionId = hash('sha512', $sessionId); $_SESSION["sessionId"] = $sessionId; $_SESSION["userId"] = $userId; $sql = "UPDATE `users` " . "SET `userSessionId` = ? " . "WHERE `userId` = ?"; $stmt = $conexion->prepare($sql); $stmt->bind_param('si', $hashedSessionId, $userId); $stmt->execute(); $stmt->close(); return $sessionId; } } return ""; }
<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <?php include 'inc/common.php'; if (!sys_session_test()) { header("Location: login.php"); } ?> <html> <head> <meta charset="UTF-8"> <title>MELOL</title> <link media="all" href="css/style.css" rel="stylesheet" type="text/css"></link> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <div id="wrapper"> <div id="header"> <div id="logo"> <img src="img/logo_web.png"></img> </div> <div id="title"> Manager Emulator LOL