session variable discrepancies between 5.5 and 7 - laravel

I run PHP 5.5 locally and 7 on live server. The trouble is with laravel session library where I am setting a session variable conditionally and then updating this where relevant. this works like charm locally, however the variable does not seem to update once set on the live server.
Does anybody know of something like this being affected by PHP 7. This is the only thing I can think of that would affect this bug.
if(in_array($currentState, Site::config('config.extra_delivery.'.$countryId.'.values')))
{
$newfulfilmentHouse = kohana::config('config.extra_delivery.'.$countryId.'.fulfilmentHouseId');
Session::set('amendFulfilmentHouse', $newfulfilmentHouse);
echo true;
}
else
{
Session::set('amendFulfilmentHouse', $origionalFulfilmentHouse);
echo true;
}
The I have a very simple ajax call that check with this line:
if(Session::get('amendFulfilmentHouse'))$currenctFulfilmentHouse = Session::get('amendFulfilmentHouse');
The else in the first function is really just as a back up in logic really. should'nt have any impact. its more based on the config.

Related

Session return null anyway

My project is using three different services and now I never can get sessions values, I've tried the laravel site tutorial and fallowing link question :
Laravel - Session returns null
But none of them worked!
In the first, i used this library:
use Session;
In a controller class :
$result = SocketHelper::sendRequest($req);
Session::put('uuid', $result->uuid);
Session::save();
Session::put('userId', $result->userID);
return Redirect::route('login_step_two');
In an other method :
$uuid = Session::get('uuid');
$userId = Session::get('userId');
But these are null! does I have to use cookie?
I recently upgrade to laravel 5.4
Please help me! It's made me confused!
Thanks.
Try saving Session explicitly like this, give it a try it worked for me, hope same for you.
Session::put('test_session', 'test message');
Session::save();
And retrieve it like this
echo Session::get('test_session');
And forget it like this:
Session::forget('test_session');
Session::save();
I understood the null result was becouse I was posting the value of $request to an other template and it was changed it the way :))) !
so easy to know !
Have you properly upgraded to laravel 5.4?
Laravel Docs
Sessions
Symfony Compatibility
Laravel's session handlers no longer implements Symfony's SessionInterface. Implementing this interface required us to implement extraneous features that were not needed by the framework. Instead, a new Illuminate\Contracts\Session\Session interface has been defined and may be used instead. The following code changes should also be applied:
All calls to the ->set() method should be changed to ->put(). Typically, Laravel applications would never call the set method since it has never been documented within the Laravel documentation. However, it is included here out of caution.
All calls to the ->getToken() method should be changed to ->token().
All calls to the $request->setSession() method should be changed to setLaravelSession().
Do you still have the rights to write session files in php session directory ?
Check the path returned by session_save_path() and check if your php user has the rights to write in it, check also if there is files in the directory and what are their creation date.

Sentry on Laravel 4 with MAMP

I'm using Laravel on MAMP PRO (PHP 5.4). Both are vanilla install and I got Laravel working okay.
Next, Installed Sentry.
Inside of a login function on controller:
$user = Sentry::authenticate($credentials, false); // this works. I can see the $user
But then upon an immediate redirect I use a filter:
Route::filter('auth.admin', function()
{
var_dump(Sentry::check()); // ** this gives me a bool(false);
die();
if ( ! Sentry::check())
{
return Redirect::route('admin.login');
}
});
So, I'm assuming that maybe there is a cookie that is not being set?
Solved...
For anyone else with this issue, this is a summary of the most common solutions on the Internet as well as how I solved my issue. I'm on MAMP/OSX, but this apparently made zero difference as I literally put up a vagrant/virtualbox and still had the same issue.
** Set 'domain' => 'yourdomain.com' in your config/session.php. EVEN IF YOU ARE ON A SUB DOMAIN like a.b.c.yourdomain.com, use ONLY the root domain (yourdomain.com) in your 'domain' variable as I just wrote it. ** This was my issue.
Make sure your session storage folder has write permissions.
Make sure you have a >0 lifetime in your session.php
Make sure you don't have whitespaces after any closing PHP which could cause the application not to shut down properly.
Try Switching between database sessions and file sessions.
As a last resort, try upgrade to 4.2, if possible. 4.1 had a known issue (as referenced in google).
Your issue is may no be with Laravel OR Sentry. It's probably a file or configuration issue as illustrated above. I pulled my hair out tracking this from Sentry to Laravel to Cookies to Session to Blah... Only to realize that it was finally a cookie issue which was caused by me not setting my ROOT domain (I was using the full

Magento Custom Controller working on local, throwing 500 error on staging server

I am having quite a strange problem. I have just pushed my local build to our staging server. I have a custom module with custom controllers which, when accessed locally, work perfectly fine. However, when I attempt to access ONE SPECIFIC controller on staging, it throws a 500 server error. All of the other controllers I wrote work except for this custom IndexController.php I wrote. Again, everything works 100% on my local build. I have triple checked all of my .htaccess files, but maybe I’m missing something.
The strangest part of all of this is that it was working on staging two days ago! I have no idea what is causing this.
Does anyone have any suggestions on how I might go about troubleshooting this? Or, by chance, a solution?
1: Clear your cache AND sessions .
2: Check if your module is installed using the free/open-source Module List Module
3 Drop some debugging code in the following method. The var_dumps will tell you which files/classes Magento's routers are looking for with your module, but can't find.
File: app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
protected function _validateControllerClassName($realModule, $controller)
{
$controllerFileName = $this->getControllerFileName($realModule, $controller);
if (!$this->validateControllerFileName($controllerFileName)) {
var_dump($controllerFileName);
return false;
}
$controllerClassName = $this->getControllerClassName($realModule, $controller);
if (!$controllerClassName) {
var_dump($controllerFileName);
return false;
}
// include controller file if needed
if (!$this->_includeControllerClass($controllerFileName, $controllerClassName)) {
var_dump($controllerFileName);
return false;
}
return $controllerClassName;
}

PHP Kohana 3.2.2 multipart form $_POST not set on MAC but works on Win

I've just encountered a weird problem. I've recently developed a medium size website using Kohana 3.2.2 + jquery + html + WAMP on Windows 7 platform. And everything seems to be working fine, until someone tries accesing the page from Mac platform. It seems that when sending some data with files in multipart form the global variable $_POST is not set, even though when debugging the data in web browser i'm able to see that DATA IS SET :| it's just not accesable by the controller with any $_POST or request->post(). I'm repeating, everything works perfectly when user is accesing page from Windows platform (tested on few separated clients), but not working when accesing from Mac platforms (tested on few separated clients).
It's killing me...
Example of what im trying to do:
In View:
user puts data into inputs (text and file types). Data is being send by form with enctype = multipart/form-data to controller's action
In controller:
$post = request->post();
if($post['sometextinput'] != '') throws exception of unknown index 'sometextinput'.
That's extremely odd. I use Kohana on a daily basis (I develop on a Mac) and have never had an issue like that. Could you post your controller and the view? I'll plug it into a dummy project and see if I can replicate the issue. If I can I'll do what I can to get it working.
EDIT:
Could it possible be an odd configuration issue?
Just for my own clarification.
You're submitting a form that contains input fields and one or more file uploads.
When viewing it on a Windows machine you can see that the data is set in $_POST or $request->post().
On OSX it's not viewable to the controller via $_POST or $request->post();
In your before method make sure you have "parent::before();". If you are already calling parent::before() try putting it as the first statement in your before() method. If that doesn't work try adding it as the last statement. It's a shot in the dark, but it's worth a try.
If you don't have a before() method then add one and call parent::before();.
I'm not sure if you were just in a hurry to type up your example above but it actually should be:
#$post = request->post(); //wouldn't recommend doing this
if($this->request->post('sometextinput') != '') throws exception of unknown index 'sometextinput'.

Symfony2 A session had already been started - ignoring session_start()

I can't use Symfony2 session in my local server. I'm getting a "Notice: A session had already been started - ignoring session_start()" error.
Same script works fine in my production server.
I'm using Xampp with PHP 5.3.5 over Windows 7. Session auto_start is off in php.ini.
Any hint will be helpfull. Thanks
I guess it's a bite late but if it can help:
Make sure your session.autostart is turned off (0) in your php.ini
The way to use the session in Symfony 2 from the controler is the following:
$session = $this->getRequest()->getSession();
// store an attribute for reuse during a later user request
$session->set('foo', 'bar');
// in another controller for another request
$foo = $session->get('foo');
// use a default value if the key doesn't exist
$filters = $session->get('filters', array());
http://symfony.com/doc/current/book/controller.html#managing-the-session
Or from the view:
{{ app.session.get('foo') }}
You should also call start() even if it is automatically called when you read/write session data (because it is recommended and getId() doesn't call it for example)
$session->start();
$id = $session->getId();
http://symfony.com/doc/master/components/http_foundation/sessions.html
The reason you may not get the error on the production server is because it's priority is 'Notice' only.

Resources