title: PHP Slim decoding JWT token
body: <p>I am new to PHP and developing restful services using jwt authorization token. I have followed <a href="https://github.com/letsila/slim3-jwt-auth-example" rel="nofollow noreferrer">this GitHub example </a>
  and have understood code to some extent but I am stuck on error on this line <code>$stmt-&gt;bindParam("user_id", $decoded-&gt;context-&gt;user-&gt;user_id);</code> saying </p>
  
  <blockquote>
    <p>Notice: Array to string conversion in C:\xampp\htdocs\slim2\src\routes.php on line.</p>
  </blockquote>
  
  <p>please help me solving this problem, I cant understand what is context->user->user_id where these are coming from. The full code is given below</p>
  
  <pre class="lang-php prettyprint-override"><code>// The route to get a secured data.
  $app-&gt;get('/restricted', function (Request $request, Response $response) {
  
  $jwt = $request-&gt;getHeaders();
  
  $key = "testsecretekey";
  
  try {
      $decoded = JWT::decode($jwt['HTTP_AUTHORIZATION'][0], $key, array('HS256'));
  } catch (UnexpectedValueException $e) {
      echo $e-&gt;getMessage();
  }
  
  if (isset($decoded)) {
      $sql = "SELECT * FROM tokens WHERE user_id = :user_id";
  
      try {
          $db = $this-&gt;db;
          $stmt = $db-&gt;prepare($sql);
          $stmt-&gt;bindParam("user_id", $decoded-&gt;context-&gt;user-&gt;user_id);
          $stmt-&gt;execute();
          $user_from_db = $stmt-&gt;fetchObject();
          $db = null;
  
          if (isset($user_from_db-&gt;user_id)) {
              echo json_encode([
                  "response" =&gt; "This is your secure resource !"
              ]);
          }
      } catch (PDOException $e) {
          echo '{"error":{"text":' . $e-&gt;getMessage() . '}}';
      }
    }
  });
  </code></pre>