以下のコードを使用していますが、問題なく動作しているようですが、Cookie 名を変更できないようです。常にデフォルトで PHPSESSID になっています。
ありがとう
//Enable composer based autoloading
require './vendor/autoload.php';
class_alias('Cartalyst\Sentry\Facades\Native\Sentry', 'Sentry');
$hasher = new Cartalyst\Sentry\Hashing\NativeHasher; // There are other hashers available, take your pick
$userProvider = new Cartalyst\Sentry\Users\Eloquent\Provider($hasher);
$groupProvider = new Cartalyst\Sentry\Groups\Eloquent\Provider;
$throttleProvider = new Cartalyst\Sentry\Throttling\Eloquent\Provider($userProvider);
$session = new Cartalyst\Sentry\Sessions\NativeSession;
// Note, all of the options below are, optional!
$options = array(
'name' => 'cartalyst_sentry', // Default "cartalyst_sentry"
'time' => null, // Default 300 seconds from now
'domain' => null, // Default ""
'path' => null, // Default "/"
'secure' => null, // Default "false"
'httpOnly' => null, // Default "false"
);
$cookie = new Cartalyst\Sentry\Cookies\NativeCookie($options);
$sentry = new Sentry(
$userProvider,
$groupProvider,
$throttleProvider,
$session,
$cookie
);
// Setup our database
$dsn = 'mysql:dbname=database;host=localhost';
$user = 'root';
$password = 'password';
$sentry::setupDatabaseResolver(new PDO($dsn, $user, $password));
try
{
// Set login credentials
$credentials = array(
'email' => 'email@gmail.com',
'password' => 'password',
);
// Try to authenticate the user
$user = $sentry::authenticate($credentials, false);
}
catch (Cartalyst\Sentry\Users\LoginRequiredException $e)
{
echo 'Login field is required.';
}
catch (Cartalyst\Sentry\Users\PasswordRequiredException $e)
{
echo 'Password field is required.';
}
catch (Cartalyst\Sentry\Users\WrongPasswordException $e)
{
echo 'Wrong password, try again.';
}
catch (Cartalyst\Sentry\Users\UserNotFoundException $e)
{
echo 'User was not found.';
}
catch (Cartalyst\Sentry\Users\UserNotActivatedException $e)
{
echo 'User is not activated.';
}
// The following is only required if throttle is enabled
catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e)
{
echo 'User is suspended.';
}
catch (Cartalyst\Sentry\Throttling\UserBannedException $e)
{
echo 'User is banned.';
}
if ($sentry::check())
{
echo 'User logged in.';
}