Skip to content

Instantly share code, notes, and snippets.

@AstDerek
Created February 17, 2013 05:12
Show Gist options
  • Save AstDerek/4970281 to your computer and use it in GitHub Desktop.
Save AstDerek/4970281 to your computer and use it in GitHub Desktop.
<?php
// Example on how to handle JSON responses
if ($session->logged_in()) {
$json_response = array(
'error' => FALSE,
'user_id' => $session->user_id()
);
}
else {
$json_response = array(
'error' => TRUE,
'reason' => 'The user is not logged in'
);
}
// Some other usage, redirection
if (!$session->logged_in()) {
/**
* redirect() would include:
* header();
* exit;
*/
$session->redirect();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment