Different answers from different browsers

I have json api addon, there is a request to get the result stored in the database, but it gives different answers on another system. I already clear the cookie and browser cache, but nothing happens. It saves the device id again and again, even it already saves

My function is this:

public function store_device_id()
{
  global $wpdb;
  $device_id = $_REQUEST['device_id'];
  $device_type = $_REQUEST['device_type'];
  $table_name = $wpdb->prefix . 'ws_details';
  if(!empty($device_id) && !empty($device_type)) :
    $check = $wpdb->get_row( "SELECT * FROM $table_name WHERE device_id like '%".$device_id."%'" );
    if($check == '')
    {
        $result = $wpdb->insert( $table_name,array( 
                'time' => current_time( 'mysql' ), 
                'device_id' => $device_id,
                'device_type' => $device_type ), 
            array( '%s', '%s', '%s'));
        if ($result) 
        {
            $res = 'Device id saved.';
        } else {
            $res = 'Device id did not save.';
        }
    }
    else{
        $res = 'Device already register.';
    }
else :
    $res = 'Please enter device id & device type.';
endif;

nocache_headers();
$post = new JSON_API_Post();
$post = $res;
return array(
      'post' => $post
    );
}

Here is the table structure

, wp_ws_details (   id mediumint (9) NOT NULL AUTO_INCREMENT,   device_id varchar (255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,   device_type varchar (55) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',   time datetime NOT NULL DEFAULT '0000-00-00 00:00:00',    id (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci AUTO_INCREMENT = 1;

+6
1

, . nocache_headers() , .

0

Source: https://habr.com/ru/post/1014792/


All Articles