Answers.Body: <p>I just tested this and it works as you'd expect it to work for me locally:</p>
  
  <pre><code>&lt;?php
  
  $craft = require '/path/to/craft/app/bootstrap.php';
  
  if ($craft-&gt;userSession-&gt;isAdmin())
  {
      echo 'I am an admin.';
  }
  else
  {
      echo 'I am not an admin.';
  }
  
  if ($craft-&gt;userSession-&gt;isLoggedIn())
  {
      echo 'I am logged in.';
  }
  else
  {
      echo 'I am not logged in.';
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-20T23:50:41.453Z
Answers.Text: I will use your script stand alone. Will report back shortly.
Answers.UserDisplayName: Luke Holder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-31T01:23:51.740Z
Answers.Text: Ever figure this out, @LukeHolder?
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-31T03:51:22.710Z
Answers.Text: will jump in right now and take a look at it again.
Answers.UserDisplayName: Luke Holder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-31T05:50:22.653Z
Answers.Text: works for me, think it was a bug with my session code for the app that was using the bootstrap.
Answers.UserDisplayName: Luke Holder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-20T22:26:50.763Z
Answers.LastActivityDate: 2014-10-20T22:26:50.763Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have an external php app that sits in a subdirectory in the public folder on the same server (and domain) as craft. I am trying to use bootstrap.php to check the logged in status of the current user. Is this possible?</p>
  
  <p>It is currently working for me by checking that the user is logged in (it does return false while not logged in) - but after the user logs out of craft the bootstrap.php continues to return true that the user is logged in.</p>
  
  <pre><code>$craft = require '../../craft/app/bootstrap.php';
  if ($craft-&gt;userSession-&gt;isAdmin() &amp;&amp; $craft-&gt;userSession-&gt;isLoggedIn() ){
   // this returns after a log in, but continues to be true after a log out. It does not return true initially before using both craft and this script.
  }
  </code></pre>
  
  <p>Hopefully that makes sense, any ideas?</p>
  
  <p>I also could not get the onLogout or onBeforeLogout to execute. I see it is in the class reference, but not listed in the event documentation:</p>
  
  <pre><code>public function init()
  {
  
      craft()-&gt;on('usersession.onLogout', function(Event $event) {
          echo "THIS DOES NOT EXECUTE";
          die();
      });
  
      parent::init();
  }
  </code></pre>
  
  <p>Is it possible the log out event is not triggering?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-20T22:27:11.523Z
Comments.Text: Where does that `init()` method live?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-20T23:49:47.573Z
Comments.Text: In the main class of the plugin.
Comments.UserDisplayName: Luke Holder
Tags: <plugin-development><session>
Title: log out being shared with bootstrap.php
ThreadText: # log out being shared with bootstrap.php
  
  (Asked by: username_0 on 2014-10-20)
  
  I have an external php app that sits in a subdirectory in the public folder on the same server (and domain) as craft. I am trying to use bootstrap.php to check the logged in status of the current user. Is this possible?
  
  It is currently working for me by checking that the user is logged in (it does return false while not logged in) - but after the user logs out of craft the bootstrap.php continues to return true that the user is logged in.
  
  ```
  $craft = require '../../craft/app/bootstrap.php';
  if ($craft->userSession->isAdmin() && $craft->userSession->isLoggedIn() ){
   // this returns after a log in, but continues to be true after a log out. It does not return true initially before using both craft and this script.
  }
  
  ```
  
  Hopefully that makes sense, any ideas?
  
  I also could not get the onLogout or onBeforeLogout to execute. I see it is in the class reference, but not listed in the event documentation:
  
  ```
  public function init()
  {
  
      craft()->on('usersession.onLogout', function(Event $event) {
          echo "THIS DOES NOT EXECUTE";
          die();
      });
  
      parent::init();
  }
  
  ```
  
  Is it possible the log out event is not triggering?
  
  **Tags:** plugin-development, session
  
  > **Comments:**
  > **username_1**: Where does that `init()` method live?  
  > **username_0**: In the main class of the plugin.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-10-20. Score: 1
  
  I just tested this and it works as you'd expect it to work for me locally:
  
  ```
  <?php
  
  $craft = require '/path/to/craft/app/bootstrap.php';
  
  if ($craft->userSession->isAdmin())
  {
      echo 'I am an admin.';
  }
  else
  {
      echo 'I am not an admin.';
  }
  
  if ($craft->userSession->isLoggedIn())
  {
      echo 'I am logged in.';
  }
  else
  {
      echo 'I am not logged in.';
  }
  
  ```
  
  > **Comments:**
  > **username_0**: I will use your script stand alone. Will report back shortly.  
  > **username_1**: Ever figure this out, @username_0?  
  > **username_0**: will jump in right now and take a look at it again.  
  > **username_0**: works for me, think it was a bug with my session code for the app that was using the bootstrap.  
  
  ---
  
  