Laravel 4.2 behind ELB - Sessions not working - php

I'm running Laravel 4.2 with database session storage.
My application is running behind a Load Balancer.
When only one instance is running, my application works fine.
Then if i enable a second instance my application stops working.
My application adds a session to the database on almost every pageload, and i can't write/read sessions (and can't login).
Here is my session config
return array(
'driver' => 'database',
'lifetime' => 1440,
'expire_on_close' => false,
'files' => storage_path().'/sessions',
'connection' => "mysql",
'table' => 'sessions',
'lottery' => array(2, 100),
'cookie' => 'ycrm_session',
'path' => '/',
'domain' => null,
'secure' => false,
);
My sessions table looks like this
Have anybody experied that issue before?

I found the problem.
I'm using forge to manage and deploy my application. When i deploy my code its running composer install and its seems to edit my config/app.php .
I just redeployed my config/app.php and its starts working.

Related

Typo3 with MSSQL [duplicate]

I tried to install TYPO3 (8.7.7) on my Webserver (IIS) and I'd like to use my SQL Server instead of MySQL.
I found lots of instructions how to make this (on typo3.org and other websites) but none of these worked for me.
I found out, that I must install two extensions before I start the installation (ADOdb & DBAL). Probably there is my fault.
Can anybody explain step by step how to install these extensions before the TYPO3 installation?
I'm using the following configuration to successfully run TYPO3 on SQL Server on my local windows machine:
'DB' => [
'Connections' => [
'Default' => [
'charset' => 'utf-8',
'dbname' => 't3',
'driver' => 'sqlsrv',
'host' => 'localhost',
'password' => 'yourPassword',
'port' => 1433,
'user' => 'sa',
],
],
],
It's a bit complicated to set up with the installer as it is not yet "clickable". What you can do is call the install script and when it's asking you to configure the database connection you go to your file system and manually add the config section above (with your connection params of course) in the LocalConfiguration.php file.
Then reload the installer - which should now recognize the configured database connection and let you go to the last step where you can import / create the base tables and data.
Note: At the moment I know of two bigger areas where SQL Server is still a problem with TYPO3 8.7 - that's workspaces and database compare. The last one means that after you have existing data in your SQL Server tables won't let you alter them via the TYPO3 database compare tool - you have to change tables manually if you need to.
Find a gist of the table create statements on https://gist.github.com/psychomieze/9570ea1f578aee7a1fbb68c3240a21c8
With 8.7, Doctrine DBAL has been integrated into the core and ADOdb & DBAL sysexts have been removed as there is no need anymore.
Take a look at the documentation of Doctrine DBAL http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html and it should fit perfectly to the configuration of the DB in `LocalConfiguration.php``
'DB' => [
'Connections' => [
'Default' => [
'charset' => 'utf8',
'dbname' => 'typo3',
'driver' => 'mysqli',
'host' => 'mysql',
'password' => 'dev',
'port' => 3306,
'user' => 'root',
],
],
],
Now my Typo3 is working.
I solved my problem a little bit complicated.
I made a test environment and installed Typo3 with MySQL.
Then I copied the database with the "Microsoft SQL Server Migration Assistant 7.6 for MySQL"
(https://www.microsoft.com/en-us/download/details.aspx?id=54257) to my main environment.
After that I copied all the created folders (typo3conf, typo3temp etc.) to my main environment
and edited the databaseconnection in the LocalConfiguration.php file like Georg Ringer proposed.
When I am installing Typo3 and MSSQL next time I will do it like susi proposed.
Thanks for your help.

Laravel Session::token keeps changing in every request when not using https://

I have read almost 100+ questions in stackoverflow about this. But nothing helped me.
My problem:
Laravel Session::token is re-generated in each HTTP request when I upload my app in my shared hosting. The app works fine when the domain has https://. But if I load the app using http://, no forms work (shows 419 Page Expired). The app also works fine in my localhost (Windows 10 with apache server) even though it's also http://localhost.
I can simply force to HTTPS using .htaccess to ignore the issue. But I want my app to be functioning in non-SSL domains also.
If I hit https://example.com/ 10 times, dd(Session::token()); returns the same token xZYdXs5UuXUSCZ5wHGELad9GuqjimkrPhMlsMepE every time.
And if I hit http://example.com/ 10 times, dd(Session::token()); returns different random tokens each time.
My Hosting Server: Litespeed
Laravel Version: 6.2
PHP Version: 7.4
.env file
SESSION_DRIVER=file
SESSION_LIFETIME=120
config/session.php file
use Illuminate\Support\Str;
return [
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => env('SESSION_CONNECTION', null),
'table' => 'sessions',
'store' => env('SESSION_STORE', null),
'lottery' => [2, 100],
'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),
'path' => '/',
'domain' => env('SESSION_DOMAIN', null),
'secure' => env('SESSION_SECURE_COOKIE', false),
'http_only' => true,
'same_site' => null,
];
Permission:
/storage 0755
/storage/framework/sessions 0755
Please let me know if I should share any relevant information to make the issue more clear.
Thank you.

Laravel - how to upload file to another application on localhost?

I'm trying to create a file upload where admin would upload file from admin application to another application for regular users (they are on different domains).
I got it working with FTP filesystem but I would like to test it on localhost, before I fully deploy it.
I made a config entry in filesystem.php:
'ftp' => [
'driver' => 'ftp',
'host' => env('FTP_HOST'),
'username' => env('FTP_USERNAME'),
'password' => env('FTP_PASSWORD'),
'root' => '',
'port' => 21,
'timeout' => 30,
'ssl' => true,
]
And on my test function in admin_app I do this:
Storage::disk('ftp')->put('/public_app/storage/test3.png', $file);
I have to separate laravel applications: admin_app and public_app. How could I test the same thing on localhost? Another config entry point or do I need to download FTP for localhost?
What about using something like remote server that contain your assets?
For example use S3 and upload all your files there and access it from your second app or any other app.
Check this Article

CakePHP cookies are not secure and not httponly

Cookies in my app are not secured and not http only, but they are configured exactly as in example on CakePHP Book 2.0 - Session Configuration.
Configure::write('Session', array(
'defaults' => 'php',
'timeout' => 30,
'cookieTimeout' => 30,
'ini' => array(
'session.cookie_secure' => true,
'session.cookie_httponly' => true
)
));
I am using SSL so this should be done automatically, but it's not happening, not even when I set this manually, see the code above. Cookie timeouts work well.
Any ideas? Thank you very much!
Here you have used default parameter is 'PHP' in this case your application takes timeout of main PHP configuration like from php.ini file. you can set it 'cake' to control your session scope.

Setting up a local version of site: config settings/issues

I've been attempting to set up a version of my website on my computer so that I stop making live updates on my website. The website runs on a PHP based CMS.
I posted a question earlier: mysql connect - Moving my website to a local host
The question was about mysql-connect - the outcome was that I connected my database to my localhost as opposed to the current live host.
Now, the local version of my site loads except all styling is gone and the nav links do not work. I suspect the answer may be to do with the same file I edited in the question above: application/config/database.php
Here is what the code looked like originally:
$config['default'] = array(
'benchmark' => TRUE,
'persistent' => FALSE,
'connection' => array(
'type' => 'mysql',
'user' => 'mywebsite',
'pass' => 'somestringoftext',
'host' => 'mywebsitecom.fatcowmysql.com',
'port' => FALSE,
'socket' => FALSE,
'database' => 'mywebsiteDB4',
Then I changed it to this:
$config['default'] = array(
'benchmark' => TRUE,
'persistent' => FALSE,
'connection' => array(
'type' => 'mysql',
'user' => 'root',
'pass' => '',// Since it's on local host there is no password right now
'host' => 'localhost',
'port' => FALSE,
'socket' => FALSE,
'database' => 'mywebsite',//this is what I called the DB I created and imported to in PHPmyadmin
It may be that this all looks correct and the issue lies elsewhere. I have a suspicion that it could be to do with the .htaccess file as, when I initially set up the site, I had issues with that, except all I had to do was set permissions. Thing is, the way the local version appears right now is very similar to how it looked when the .htaccess file was not "working".
I realize that I've just dropped a bunch of code and said "help"! I'm really stuck on where to look next. If anyone does have any ideas I'd be grateful to hear them. If any further info could help anyone with suspect ideas please let me know and I'l update.
If site loads and you can see at page data taken from database, it means, what you DB connection is OK.
Since you can't see styling and menu not works, it means what you .JS/.CSS files not loaded correctly from you local server.
You can use addon FireFox called FireBug and here "Net" tab, to see which files loaded correctly and which not. For not loaded files you will need or change path to include it in you HTML file or change files location in you local filesystem

Categories