45d57a597194bf6399760855076a63580a72343c
[WebKit-https.git] / Websites / perf.webkit.org / public / privileged-api / generate-csrf-token.php
1 <?php
2
3 require_once('../include/json-header.php');
4
5 ensure_privileged_api_data();
6
7 $user = array_get($_SERVER, 'REMOTE_USER');
8
9 $expiritaion = time() + 3600; // Valid for one hour.
10 $_COOKIE['CSRFSalt'] = rand();
11 $_COOKIE['CSRFExpiration'] = $expiritaion;
12
13 setcookie('CSRFSalt', $_COOKIE['CSRFSalt']);
14 setcookie('CSRFExpiration', $expiritaion);
15
16 exit_with_success(array('user' => $user, 'token' => compute_token(), 'expiration' => $expiritaion * 1000));
17
18 ?>