Skip to content

Instantly share code, notes, and snippets.

@woganmay
Created February 12, 2017 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woganmay/4a08dd348fdaec3900c6f0cb6c6e3b08 to your computer and use it in GitHub Desktop.
Save woganmay/4a08dd348fdaec3900c6f0cb6c6e3b08 to your computer and use it in GitHub Desktop.
Check for Flarum authentication before the main site even loads
<?php
if (isset($_COOKIE['flarum_remember']))
{
$mysql = new mysqli("localhost", "flarum_sql_user", "flarum_sql_pass", "flarum_database");
$result = $mysql->query("SELECT * FROM access_tokens WHERE id = '". $mysql->real_escape_string($_COOKIE['flarum_remember']) ."'");
if ($result->num_rows == 0)
{
// Invalid cookie
header('Location:https://my.laravel.site/login');
exit;
}
}
else
{
// No cookie
header('Location:https://my.laravel.site/login');
exit;
}
// Rest of normal index.php here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment