Support the ongoing development of Laravel.io →
Authentication Session
Last updated 2 years ago.

mineland405 liked this thread

1

Hello, I am having the same problem, do I log in, but it gets lost soon after, even before redirecting it has lost the session and returns to the login. Have you had any success in your problem?

Last updated 2 years ago.

mineland405 liked this reply

1

quinhone said:

Hello, I am having the same problem, do I log in, but it gets lost soon after, even before redirecting it has lost the session and returns to the login. Have you had any success in your problem?

Apparently not. And I figured that it's seems just few of us having this problem, after searching few days, mostly the answer is to recreate laravel project (which I did) or deactivate some dependent packages (however I am not having particular packages). As an additional information I don't have this problem in Windows/XAMPP environment, the problem just occurred when I try to migrate/create new laravel project in MacOS/MAMP environment.

Last updated 2 years ago.

mineland405 liked this reply

1

I'm having the same problem in a MAMP 3.0 environment. This has become a complete blocker to my project since we are a a Mac only shop. Does anyone know a solution or even an exact cause?

Last updated 2 years ago.

mineland405 liked this reply

1

I found the issue in my case. I'll post the solution in the hopes that it helps someone else in the future.

My User class was defined as:

Schema::create('users', function(Blueprint $table)
{
    $table->string('identifier')->unique();
    $table->string('username')->unique();
    $table->string('email')->unique();
    $table->string('password', 60);
    $table->boolean('isActive')->default(false);
    $table->timestamps();
});

You may note that it didn't have a primary key field. By adding

$table->increments('id');

to the definition, and rebuilding the migration, it started working.

Last updated 2 years ago.

mineland405 liked this reply

1

I have a similar problem (http://laravel.io/forum/03-20-2014-not-able-to-create-session), have you found a solution yet?

Last updated 2 years ago.

mineland405 liked this reply

1

None found the exact cause yet. <sigh>

Last updated 2 years ago.

mineland405 liked this reply

1

Please keep in mind that all users should have an id in the database!

Check your user(s) table in your database and make sure it has a column with id. Laravel will destroy the session if you do not have this or named it differently from id.

Last updated 2 years ago.

manu-applab, mineland405 liked this reply

2

I had the same issue, but it has been resolved by changing my table id column name specifically to "id". I don't love that there is no user defined way to set this, but that appears to be the problem and it is working now.

Last updated 2 years ago.

mineland405 liked this reply

1

If your primary key is named something other than "id" then try adding the following to your Eloquent model

/**
 * The primary key for the model.
 *
 * @var string
 */
protected $primaryKey = 'name_of_primary_key';

Change name_of_primary_key to whatever you named your primary key.

Last updated 2 years ago.

mineland405 liked this reply

1

Hi. I am trying to deploy my app on GoDaddy hosting. On my VPS everything works great, but on GoDaddy (as I figured out) sessions are broken. I cannot log in.

I have standard login form with _token hidden field. My sign in function:

	public function postSignIn() {
		if (Auth::attempt(array('email'=>Input::get('email'), 'password'=>Input::get('password'), 'active'=>true))) {
			return Redirect::intended('/')->with('message', 'Logged in!');
		} else {
			return Redirect::back()
				->with('message', 'Invalid data/inactive account.')
				->withInput();
		}
	}

after executing:

return Redirect::intended('/')->with('message', 'Logged in!');

For about 1-2 seconds shows up a message "Redirecting to [URL]", and I think that then session data resets. Auth::check on / route fails, and I am redirected to login page.

What I've checked:

  • Session driver: file (app/storage permission set to 755), files appear in directory.
  • Session domain: trying both null and '.mydomain.com'.
  • presence of id column in user model
  • and almost all of the other tips I've found here.
Last updated 2 years ago.

mineland405 liked this reply

1

And it can be similar to this problem: http://laravel.io/forum/04-09-2014-redirectto-in-auth-filter-displays-plain-text-message-redirecting-to-url Sample test route doesn't show "Redirecting to [URL]" message.

Last updated 2 years ago.

mineland405 liked this reply

1

I was facing the same issue. I just upgraded to php 5.5 and it worked.

mineland405 liked this reply

1

I have found a solution for exatly the same problem(Laravel 5.0).

I was logging in the user, checking session and everything was OK. Then, after redirect, session contained only "_token" string.

Somewhere in the depths of Internet I found a mention about UTF-8 and BOM headers. Therefore I checked all my files for this BOM. Here's how http://stackoverflow.com/questions/204765/elegant-way-to-search-for-utf-8-files-with-bom

Turned out my config/mail.php file had BOM header. Saving it with Notepad++ chosing option "UTF-8 w/o BOM" solved the problem.

If you wonder how a BOM header could have been added to your file, in my case it was like that: I normaly use Notepad++ to change files using FTP protocol(NppFTP plugin). I only needed to update one administrator email in my mail.php configuration file, so, out of pure laziness, I opened this file from Total Commander using default Windows Notepad and this sucker not only didn't show any line breaks(all file in one line) but also saved that file with BOM headers.

Hope I helped someone, because I saw lots of articles/threads/questions all over Web with the same problem.

Last updated 9 years ago.

mineland405 liked this reply

1

I have the same problem

kejwmen said:

Hi. I am trying to deploy my app on GoDaddy hosting. On my VPS everything works great, but on GoDaddy (as I figured out) sessions are broken. I cannot log in.

I have standard login form with _token hidden field. My sign in function:

  public function postSignIn() {
  	if (Auth::attempt(array('email'=>Input::get('email'), 'password'=>Input::get('password'), 'active'=>true))) {
  		return Redirect::intended('/')->with('message', 'Logged in!');
  	} else {
  		return Redirect::back()
  			->with('message', 'Invalid data/inactive account.')
  			->withInput();
  	}
  }

after executing:

return Redirect::intended('/')->with('message', 'Logged in!');

For about 1-2 seconds shows up a message "Redirecting to [URL]", and I think that then session data resets. Auth::check on / route fails, and I am redirected to login page.

What I've checked:

  • Session driver: file (app/storage permission set to 755), files appear in directory.
  • Session domain: trying both null and '.mydomain.com'.
  • presence of id column in user model
  • and almost all of the other tips I've found here.

mineland405 liked this reply

1

Has anybody came out with other solution? I have the same issue with GoDaddy. It was working before, and I've been adding new things, and I don't know which one is the problem.

Thx!

mineland405 liked this reply

1

I've experienced the same today. I'm using Sentry as my auth and user management, after login user will be redirected to their profile but session get destroyed. Apparently, KKSzymanowski solved my issue. I added a new model with space before or one line <?php. So in my case, it's just a BOM issue. I hope everyone won't experience the same thing.

mineland405 liked this reply

1

Sign in to participate in this thread!

Eventy

Your banner here too?

arthipesa arthipesa Joined 10 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.