| Conditions | 3 |
| Paths | 2 |
| Total Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | public static function makeToken() |
||
| 34 | { |
||
| 35 | // token is valid for 1 day |
||
| 36 | $max_time = 60 * 60 * 24; |
||
| 37 | $stored_time = Session::get('csrf_token_time'); |
||
| 38 | $csrf_token = Session::get('csrf_token'); |
||
| 39 | |||
| 40 | if ($max_time + $stored_time <= time() || empty($csrf_token)) { |
||
| 41 | Session::set('csrf_token', md5(uniqid(rand(), true))); |
||
| 42 | Session::set('csrf_token_time', time()); |
||
| 43 | } |
||
| 44 | |||
| 45 | return Session::get('csrf_token'); |
||
| 46 | } |
||
| 47 | |||
| 61 |