Skip to content

Instantly share code, notes, and snippets.

@NirmalAriyathilake
Last active October 26, 2018 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NirmalAriyathilake/80abc1ac452a70a39e562a54c95d1fff to your computer and use it in GitHub Desktop.
Save NirmalAriyathilake/80abc1ac452a70a39e562a54c95d1fff to your computer and use it in GitHub Desktop.
Synchronizer Token Pattern - Index.php
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Synchronizer Token Pattern</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<?php
session_start();
//Setting the session ID cookie
//getting the session id
$sessionID = session_id();
$expireTime = time() + 60*60; // expire time 1 hour
$cookieName = "sessionCookie";
setcookie ($cookieName, $sessionID, $expireTime, "/","localhost", FALSE, TRUE);
?>
<body>
<div class="container" style="margin-top: 100px">
<h2 class="text-center">Login</h2>
<div class="row justify-content-center">
<div class="col-md-9">
<form method="post" action="server.php" name="loginform">
Username:<br/>
<input type="text" name="username" class="form-control" placeholder="Username" required><br/>
Password:<br/>
<input type="password" name="password"class="form-control" placeholder="Password" required><br/>
<input type="submit" name="submit" value="Login" class="btn btn-success"/>
</form>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment