Vuk Stanković Vuk Stanković - 1 year ago 182
PHP Question

Session not working in Laravel 4

I have a problem with Session that won't persist.

In controller I have a function that loads a article for editing

public function getEdit($id)
try {
$news = News::findOrFail($id);
View::share('title', Lang::get('admin.editNews').": ".$news->title);
View::share('news', $news);
$this->layout->content = View::make('news.editNews');
} catch (Exception $e) {
Session::flash('message', Lang::get('admin.noSuchNews'));
Session::flash('notif', 'danger');
return Redirect::to("news");

And I have another function - index, that should display these flash messages.

public function getIndex()

Session is just not persisting. Not working with
, not working with

is just always

I guess I should mention that I did application routing like this:

Route::controller('news', 'NewsController');

Answer Source

Ok, I have fixed this.

Thing is, that I have put into session.php file this

'domain' => '',

But since app is still in localhost, everything with session was failing even though I wasn't using cookie as my Session driver.

When I changed this to

'domain' => '',

Everything started working

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download