Skip to content

Instantly share code, notes, and snippets.

@woganmay

woganmay/index.php

Created Feb 12, 2017
Embed
What would you like to do?
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