Answers.Body: <p>Assuming you want to do this from your transformer, then something like this should work:</p>
  
  <pre><code>'transformer' =&gt; function($entry) {
  
      $isLoggedIn = craft()-&gt;userSession-&gt;isLoggedIn(); 
  
      if ($isLoggedIn) {
          // Do your custom logic.
      }
  
      return array(
          'title' =&gt; $entry-&gt;title,
          'url' =&gt; $entry-&gt;url,
          'description' =&gt; (string) $entry-&gt;description,
          'photos' =&gt; $photos
      );
  },
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-06T18:36:17.337Z
Answers.Text: huh - that's easy :)
Answers.UserDisplayName: Steven Grant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-05T21:02:13.717Z
Answers.LastActivityDate: 2017-06-05T21:02:13.717Z
Answers.UserDisplayName: Brad Bell
Body: <p>Working on a SPA with Vue and Craft and looking to check if a user is logged in to run some Vue conditional logic.</p>
  
  <p>I imagine that will then enable me to check if the logged in user owns content to return as well?</p>
  
Tags: <plugin-elementapi>
Title: Check for logged in user with the Element API plugin
ThreadText: # Check for logged in user with the Element API plugin
  
  (Asked by: username_0 on 2017-06-05)
  
  Working on a SPA with Vue and Craft and looking to check if a user is logged in to run some Vue conditional logic.
  
  I imagine that will then enable me to check if the logged in user owns content to return as well?
  
  **Tags:** plugin-elementapi
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-06-05. Score: 2 | Accepted answer
  
  Assuming you want to do this from your transformer, then something like this should work:
  
  ```
  'transformer' => function($entry) {
  
      $isLoggedIn = craft()->userSession->isLoggedIn(); 
  
      if ($isLoggedIn) {
          // Do your custom logic.
      }
  
      return array(
          'title' => $entry->title,
          'url' => $entry->url,
          'description' => (string) $entry->description,
          'photos' => $photos
      );
  },
  
  ```
  
  > **Comments:**
  > **username_0**: huh - that's easy :)  
  
  ---
  
  