必要な列を含む「users」テーブルを適切に作成したと仮定します。Laravel のビルトイン認証システムを使用して、ユーザーがログインしているかどうかを確認できます。あなたの場合、ユーザーがログインしていない場合は、先に進んでランダムなユーザーを作成し、それでログインしたいようです。これは、役立つはずのコメント付きのコード サンプルです。
セッションに関する限り、Laravel の組み込み認証を使用している場合は、セッションについてまったく心配する必要はありません。Laravel がすべて処理してくれます。
編集
これはすべてコントローラーで行われます。
<?php
// First ask Laravel if the user is logged in.
if (Auth::guest())
{
// If not, let's create a new user, save it, then log in with that newly created user.
$newUser = new User;
$newUser->username = str_random();
$newUser->password = Hash::make(str_random());
$newUser->save();
// This login() function allows us to just login someone in without any hassle.
// If you were collecting and checking login credentials, that's when you would use attempt()
Auth::login($newUser)
}
else
{
// He is already logged in. You can then access his user information like so...
$user = Auth::user();
$user->username; // Would return his username.
}
// At this point, the user is defintely logged in one way or another. So we can then send the view as normal.
return View::make('members.home');