Skip to content

Commit

Permalink
Add files via upload - File name token.php
Browse files Browse the repository at this point in the history
  • Loading branch information
jcavenue authored May 24, 2021
1 parent 362d48c commit 6424d67
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions token.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
class token {

public static function generate(){
return $_SESSION['token'] = base64_encode(openssl_random_pseudo_bytes(32));
}

public static function check($token){
if(isset($_SESSION['token']) && $token === $_SESSION['token']){
unset($_SESSION['token']);
return true;
}
return false;
}

public static function sessionStart(){
session_set_cookie_params(0,'/','localhost',true,true);
session_start();
}
}
?>

0 comments on commit 6424d67

Please sign in to comment.