How to configure session in CakePHP 3

Let’s see how can we configure session in cakePHP to something safer.

1. Open config/app.php file
2. Scroll down to the end of file and locate:

'Session' => [
    'defaults' => 'php',
],

and change it to this:

'Session' => [
    'defaults'  =>  'database',
	'cookie'    =>  'webapptest',
	'timeout'   =>  24,     //minutes
	'ini'       =>  [
		'session.gc_divisor'        =>  1000,
		'session.cookie_secure'     =>  true,
		'session.cookie_path'       =>  '/',
		'session.cookie_domain'     =>  'your_domain_name_or_subdomain',
		'session.cookie_httponly'   =>  true,
		'session.cookie_lifetime'   =>  1440,   //seconds
	],
],
Categories: CakePHP, PHP Tags: ,
%d bloggers like this: