3v4l.org

run code in 300+ PHP versions simultaneously
<?php function newRememberMeCookie($id) { // generate 64 char random string and store it in current user data $random_token_string = hash('sha256', mt_rand()); $sql = "INSERT INTO lib_usercookies(user_id, user_cookies) VALUES (:user_id, :user_cookies)"; // generate cookie string that consists of userid, randomstring and combined hash of both $cookie_string_first_part = $random_token_string; $cookie_string_hash = hash_hmac('sha1', $cookie_string_first_part, "1gp@TMPS{+$78sfpMJFe-92s"); $cookie_string = $cookie_string_first_part . ':' . $cookie_string_hash; // set cookie setcookie('cri1432', $cookie_string, (time() + 60 * 60 * 24), '/', ".127.0.0.1"); } var_dump(newRememberMeCookie(1));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Pgr0q
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'newremembermecookie'
          2        SEND_VAL                                                 1
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function newremembermecookie:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Pgr0q
function name:  newRememberMeCookie
number of ops:  30
compiled vars:  !0 = $id, !1 = $random_token_string, !2 = $sql, !3 = $cookie_string_first_part, !4 = $cookie_string_hash, !5 = $cookie_string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'hash'
          2        SEND_VAL                                                 'sha256'
          3        INIT_FCALL                                               'mt_rand'
          4        DO_ICALL                                         $6      
          5        SEND_VAR                                                 $6
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !1, $7
    8     8        ASSIGN                                                   !2, 'INSERT+INTO+lib_usercookies%28user_id%2C+user_cookies%29+VALUES+%28%3Auser_id%2C+%3Auser_cookies%29'
   10     9        ASSIGN                                                   !3, !1
   11    10        INIT_FCALL                                               'hash_hmac'
         11        SEND_VAL                                                 'sha1'
         12        SEND_VAR                                                 !3
         13        SEND_VAL                                                 '1gp%40TMPS%7B%2B%2478sfpMJFe-92s'
         14        DO_ICALL                                         $11     
         15        ASSIGN                                                   !4, $11
   12    16        CONCAT                                           ~13     !3, '%3A'
         17        CONCAT                                           ~14     ~13, !4
         18        ASSIGN                                                   !5, ~14
   14    19        INIT_FCALL                                               'setcookie'
         20        SEND_VAL                                                 'cri1432'
         21        SEND_VAR                                                 !5
         22        INIT_FCALL                                               'time'
         23        DO_ICALL                                         $16     
         24        ADD                                              ~17     $16, 86400
         25        SEND_VAL                                                 ~17
         26        SEND_VAL                                                 '%2F'
         27        SEND_VAL                                                 '.127.0.0.1'
         28        DO_ICALL                                                 
   15    29      > RETURN                                                   null

End of function newremembermecookie

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.45 ms | 1403 KiB | 26 Q