Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth::attempt() showing error in Linux server #1257

Closed
tanvirgaus opened this issue May 10, 2013 · 29 comments
Closed

Auth::attempt() showing error in Linux server #1257

tanvirgaus opened this issue May 10, 2013 · 29 comments

Comments

@tanvirgaus
Copy link

Not sure what's wrong, it works in my local dev environment but not in the server. all other DB related function works but not Auth::attempt()
Warning: array_diff() [function.array-diff]: Argument #1 is not an array in .../web/bootstrap/compiled.php line 11346

$user = array(
'username' => 'myuser',
'password' => 'abc'
);
if (Auth::attempt($user)) {
echo "Here I am : " .Auth::user()->id;
}

FYI - I'm running xampp 1.8.1 in windows7 with PHP 5.4.7 and my server is Linux bluejays with PHP 5.3.13

I changed the flash() in bootstrap/compiled.php like this
public function flash($key, $value)
{
$this->put($key, $value);
$this->push('flash.new', $key);
$old = $this->get('flash.old');
$old = (empty($old)) ? array() : $old;
$this->put('flash.old', array_diff($old, array($key)));
}

Then I managed to make it work and get the "Here I am : 1" but it didn't set anything in the session

@taylorotwell
Copy link
Member

Try deleting the bootstrap compiled file and composer updating.

On May 9, 2013, at 8:08 PM, Tanvir Gaus notifications@github.com wrote:

Not sure what's wrong, it works in my local dev environment but not in the server. all other DB related function works but not Auth::attempt()
Warning: array_diff() [function.array-diff]: Argument #1 is not an array in .../web/bootstrap/compiled.php line 11346

$user = array(
'username' => 'myuser',
'password' => 'abc'
);
if (Auth::attempt($user)) {
echo "Here I am : " .Auth::user()->id;
}

FYI - I'm running xampp 1.8.1 in windows7 with PHP 5.4.7 and my server is Linux bluejays with PHP 5.3.13

I changed the flash() in bootstrap/compiled.php like this
public function flash($key, $value)
{
$this->put($key, $value);
$this->push('flash.new', $key);
$old = $this->get('flash.old');
$old = (empty($old)) ? array() : $old;
$this->put('flash.old', array_diff($old, array($key)));
}

Then I managed to make it work and get the "Here I am : 1" but it didn't set anything in the session


Reply to this email directly or view it on GitHub.

@tanvirgaus
Copy link
Author

It was same.
Got the issue, Needed to make the /app/storage writable
its working now thanks

@tanvirgaus
Copy link
Author

NO I was wrong its not working.
The Auth::attempt($user) works and getting "Here I am : 1" but when redirecting to other page the session is gone. Auth:check() fail so somehow its not keeping the state when redirecting to different page.

BTW I have my storage folder writable.

@tanvirgaus tanvirgaus reopened this May 10, 2013
@tanvirgaus
Copy link
Author

I tried to set the user object into the session & retrieve that in the redirected page but seems Session::put() is not working at all. nothings getting set when I try to Session::get() in the redirected page.

I debug more and seems like you used different functions for different PHP version. in the NativeSessionStorage I found different code for different PHP versions

if (version_compare(phpversion(), '5.4.0', '>=')) {
session_register_shutdown();
} else {
register_shutdown_function('session_write_close');
}
I assume this is something related to the version and could you check if the code works < 5.4?

@taylorotwell
Copy link
Member

Your session probably isn't being written because your dumping crap out to the browser with var_dump etc.

On May 10, 2013, at 3:16 AM, Tanvir Gaus notifications@github.com wrote:

I tried to set the user object into the session & retrieve that in the redirected page but seems Session::put() is not working at all. nothings getting set when I try to Session::get() in the redirected page.

I debug more and seems like you used different functions for different PHP version. in the NativeSessionStorage I found different code for different PHP versions

if (version_compare(phpversion(), '5.4.0', '>=')) {
session_register_shutdown();
} else {
register_shutdown_function('session_write_close');
}
I assume this is something related to the version and could you check if the code works < 5.4?


Reply to this email directly or view it on GitHub.

@tanvirgaus
Copy link
Author

My Controller:

$login = array(
'username' => $input['username'],
'password' => $input['password']
);
if (Auth::attempt($login)) {
return Redirect::route('home')->with('flash_notice', 'You are successfully logged in.');
}


in home:

if(Auth::check()) {
echo "Logged in";
} else {
echo "Not logged in";
}

@taylorotwell
Copy link
Member

I use sessions on a large 5.3 app on Laravel 4 and they work properly. Quit echoing stuff in that home route... just use return to return your content.

@tanvirgaus
Copy link
Author

Same. No use. Session::put is not working at all

@taylorotwell
Copy link
Member

What session driver? Also, I want you to make two routes:

Route::get('put', function()
{
     Session::put('foo', 'bar');

     return 'Done';
});

Route::get('get', function()
{
     return Session::get('foo');
});

@tanvirgaus
Copy link
Author

Nothing. /put shows Done then /get shows blank
I'm using native driver, tried cookie same result

@taylorotwell
Copy link
Member

OK, post as much information about this installation as possible. Any
packages used. OS, PHP version, etc.

On Fri, May 10, 2013 at 8:45 AM, Tanvir Gaus notifications@gh.neting.ccwrote:

Nothing. /put shows Done then /get shows blank
I'm using native driver, tried cookie same result


Reply to this email directly or view it on GitHubhttps://github.com//issues/1257#issuecomment-17720862
.

@tanvirgaus
Copy link
Author

Is the session using Symfony2? if yes then http://symfony.com/doc/2.0/reference/requirements.html shows prerequisite is PHP 5.3.2 at least. My server is having 5.3.13
Is your app running in < 5.3.2?

@taylorotwell
Copy link
Member

I have a Laravel 4 app on 5.3.10. Works fine.

@tanvirgaus
Copy link
Author

FYI the same server is running Laravel 3 application without any issues

@taylorotwell
Copy link
Member

Post packages used, etc. Entire routes file, etc.

@tanvirgaus
Copy link
Author

From PHP info -
System Linux texans 2.6.32.45-grsec-2.2.2-r3 #8 SMP Mon Oct 10 13:33:17 PDT 2011 x86_64
Build Date Jun 7 2012 17:50:36
Configure Command './configure' '--prefix=/usr/local/php53' '--datadir=/usr/local/php53/share' '--localstatedir=/usr/local/php53/var' '--without-pear' '--with-config-file-path=/etc/php53' '--with-config-file-scan-dir=/etc/php53/conf.d' '--enable-force-cgi-redirect' '--enable-trans-sid' '--with-zend-vm=GOTO' '--enable-cgi' '--enable-libxml=shared' '--enable-bcmath=shared' '--enable-calendar=shared' '--enable-ctype=shared' '--enable-dom=shared' '--enable-exif=shared' '--enable-fileinfo=shared' '--enable-filter=shared' '--enable-ftp=shared' '--enable-hash=shared' '--enable-intl=shared' '--enable-json=shared' '--enable-mbstring' '--enable-mbregex' '--enable-mbregex-backtrack' '--enable-pcntl=shared' '--enable-pdo' '--enable-phar=shared' '--enable-posix=shared' '--enable-session=shared' '--enable-shmop=shared' '--enable-simplexml=shared' '--enable-soap=shared' '--enable-sockets=shared' '--enable-sysvmsg=shared' '--enable-sysvsem=shared' '--enable-sysvshm=shared' '--enable-tokenizer=shared' '--enable-wddx=shared' '--enable-xml=shared' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--enable-zip=shared' '--with-openssl=shared' '--with-kerberos' '--with-pcre-regex' '--with-sqlite3' '--with-zlib=shared' '--with-bz2=shared' '--with-curl=shared' '--with-gd=shared' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-zlib-dir=/usr' '--with-xpm-dir=/usr' '--with-freetype-dir=/usr' '--with-gettext=shared' '--with-gmp=shared' '--with-mhash=shared' '--with-iconv=shared' '--with-imap=shared' '--with-imap-ssl' '--with-ldap=shared' '--with-mcrypt=shared' '--with-msql=shared' '--with-mysql=shared' '--with-mysql-sock=/No-MySQL-hostname-was-specified' '--with-mysqli=shared' '--with-pdo-mysql=shared' '--with-pdo-pgsql=shared' '--with-pdo-sqlite' '--with-pgsql=shared' '--with-pspell=shared' '--with-readline=shared' '--with-sqlite=shared' '--with-tidy=shared' '--with-xmlrpc=shared' '--with-xsl=shared'

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

@tanvirgaus
Copy link
Author

Route::any('/', array("as" => "home", "uses" => "PageController@index"));
Route::get('about', array("as" => "about", "uses" => "PageController@about"));
Route::get('play', array("as" => "play", "uses" => "UserActionController@play"));

//Works with both registration and the login
Route::get('login', array("as" => "login", "uses" => "UserController@index"))->before('guest');;

Route::post('login', "UserController@checkLogin");
Route::post('register', array("as" => "register", "uses" => "UserController@register"));

Route::get('logout', array('as' => 'logout', function () {
Auth::logout();
return Redirect::route('home')
->with('flash_notice', 'You are successfully logged out.');
}));

Route::get('put', function() {
Session::put('foo', 'bar');
return 'Done';
});

Route::get('get', function() {
return Session::get('foo');
});

@taylorotwell
Copy link
Member

What about packages? Anything installed from Composer? Using anything like Firebug etc in your browser?

@taylorotwell
Copy link
Member

I just ran a clean Laravel installation on PHP 5.3.10 (Ubuntu 12.04) and the session works prefectly, so I know it isn't broken on 5.3.

@taylorotwell
Copy link
Member

What about your mangled compiled file that you edited yourself? Have you deleted that and composer updated?

@tanvirgaus
Copy link
Author

yes I did. I didn't change anything in the core/compiled files. I just
added controller, models and routes.

-- Tanvir Gaus

On Sat, May 11, 2013 at 12:19 AM, Taylor Otwell notifications@gh.neting.ccwrote:

What about your mangled compiled file that you edited yourself? Have you
deleted that and composer updated?


Reply to this email directly or view it on GitHubhttps://github.com//issues/1257#issuecomment-17722715
.

@taylorotwell
Copy link
Member

Well, I don't know. I'm sort of out of options at this point. It works for PHP 5.3 both on my company's production server and my personal 5.3 VM.

@tanvirgaus
Copy link
Author

Is there any issue with shared hosting?

@taylorotwell
Copy link
Member

I don't know. Would depend on the host and their settings I guess.

@taylorotwell
Copy link
Member

Going to close this as it doesn't appear to be a bug in the framework. I would post on the forums maybe and see if anyone else has had similar issues on certain hosts.

@ghost
Copy link

ghost commented Jul 22, 2015

same problem !!!

@spurdow
Copy link

spurdow commented Mar 22, 2016

im having the sample problem, i spent whole freaking day!!!

After saving in Auth::login create or retrieve users function , I print Auth:;users() and isnt empty, but when it redirected its gone!

im using php 5.6

PHP 5.6.4-4ubuntu6.4 (cli) (built: Oct 28 2015 01:21:29)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

Laravel 5.2

Im using redis on my session then back on file and then back again to redis. no luck!

please help!

@spurdow
Copy link

spurdow commented Mar 22, 2016

My second attempt, Redis is working , but Session is not.

How do I configure Redis as my Session??

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

@laravel laravel locked and limited conversation to collaborators Mar 22, 2016
@GrahamCampbell
Copy link
Member

Feel free to discuss on the forums.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants