Setting cookie_httponly in zend framework doesn't work - php

I want to enable httponly cookies in my zend based application. In order to do so, I added below line in application.config.php
'cookie_httponly' => true
to existing session_config array and it looks like below
'session_config' => [
// Set the session and cookie expiries to 15 minutes
'cache_expire' => 1800,
'cookie_lifetime' => 1800,
'cookie_httponly' => true
],
But it doesn't work. Any ideas ?

See the documentation https://framework.zend.com/manual/2.4/en/modules/zend.session.manager.html
And put your config under the line 'name' => 'myapp',

Related

Laravel Debugbar few tabs are not showing e.g. Route, Auth, Session, Gate

I am using Laravel Debugbar https://github.com/barryvdh/laravel-debugbar with Laravel 7.x according to documentation it should be show this
but my debugbar missing few tabs Route, Auth, Session, Gate etc. please see below
Please Help i can get above shown tabs
Regards,
Thanks in advance
Publish the config debugbar.php in /config
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
you can customize tabs in the config/debugbar.php :
...
'collectors' => [
'phpinfo' => true, // Php version
'messages' => true, // Messages
'time' => true, // Time Datalogger
'memory' => true, // Memory usage
'exceptions' => true, // Exception displayer
'log' => true, // Logs from Monolog (merged in messages if enabled)
'db' => true, // Show database (PDO) queries and bindings
'views' => true, // Views with their data
'route' => true, // Current route information
'auth' => false, // Display Laravel authentication status
'gate' => true, // Display Laravel Gate checks
'session' => true, // Display session data
'symfony_request' => true, // Only one can be enabled..
'mail' => true, // Catch mail messages
'laravel' => false, // Laravel version and environment
'events' => false, // All events fired
'default_request' => false, // Regular or special Symfony request logger
'logs' => false, // Add the latest log messages
'files' => false, // Show the included files
'config' => false, // Display config settings
'cache' => false, // Display cache events
'models' => true, // Display models
],
....
don't forget to do
php artisan config:clear
if you use config cache
I tried composer dump-autoload and php artisan config:clear and it resolved my problem thanks to all to help me
I am using Laravel 8.x and the Debugbar was not showing the Auth tab. This seems to be the default setting. I published it using the instructions above, and edited the config/debugbar.php file setting 'auth' to true. What I missed, since I am new to PHP/Laravel, is that I should have edited the config/debugbar.php and not the vendor/barryvdh/config/debugbar.php. Once I edited the correct file, the tab was displayed. Thanks to all who contributed.

zend framework session expires or destroy config settings

Is there a way to destroy a session on the (Apache) server after for example one hour? Now the session stays in the Apache folder for ever, so each time i start the application the old session is picked (And i don't want that).
use Zend\Session\Storage\SessionArrayStorage;
use Zend\Session\Validator\RemoteAddr;
use Zend\Session\Validator\HttpUserAgent;
return [
// Session configuration.
'session_config' => [
// Session cookie will expire in 1 hour.
'cookie_lifetime' => 60*60,
// Store session data on server for 1 hour.
'gc_maxlifetime' => 60*60,
],
// Session manager configuration.
'session_manager' => [
// Session validators (used for security).
'validators' => [
RemoteAddr::class,
HttpUserAgent::class,
]
],
// Session storage configuration.
'session_storage' => [
'type' => SessionArrayStorage::class
],
// ...
];

Error when installed Yii2

I've install Yii2 framework using composer but get this error in my browser (on localhost):
Invalid Configuration – yii\base\InvalidConfigException
yii\web\Request::cookieValidationKey must be configured with a secret key.
How can I solve this problem?
There is this problem with basic app now https://github.com/yiisoft/yii2-app-basic/issues/69 where composer install doesn't generate this key.
You need to add this key manually.
Go to /config/web.php.
Edit the line 'cookieValidationKey' => '', to include random string (you can use anything like 'cookieValidationKey' => 'jfsbkjsbfdskjgfdskjbgfsdhjgfajds',
You need to set cookieValidationKey in the config file to a random string. The config file is located under yii/your-projectfolder/config/main-local.php if you are using Yii 2.0 Advanced Template
You need to set cookieValidationKey value in project/config/web.php at line 12.
change at:
'cookieValidationKey' => '',
replace with:
'cookieValidationKey' => 'setyourkey',
That should address the issue.
Try this
open Frontend/ config / main.php
'components' => [
'request' => [
'enableCookieValidation' => true,
'enableCsrfValidation' => true,
// 'cookieValidationKey' => 'xxxxxxx', // if u dont hv key just comment it
],
],
if you have a web.php
'components' => [
'request' => [
'enableCookieValidation' => true,
'cookieValidationKey' => 'your-validation-key',
],

Yii2 session problems for multiple application in single domain

We configured like /var/www/app1 and /var/www/app2 , Both are logging in single session. How can I make this different session.
I tried with following solution from yii2 wiki. But it doesn't workout here.
'identityCookie' => [
'name' => '_backendUser', // unique for backend
'path'=>'/advanced/backend/web' // correct path for the backend app.
]
Please give solution for this issue.
Use a different session $name for each application. This can be set in your config as:
'components' => [
'session' => [
'class' => '\yii\web\Session',
'name' => 'mycustomname',

data.timezone in fpm/php.ini has no effect

sorry for the mistakes I've made, I'm not Englishman.
Now I'm trying to set my timezone in php.ini correctly (/etc/php5/fpm/php.ini). Whatever I typed opposite date.timezone (UTC, GMT, Europe/Moscow etc) no one is worked. However, when I set timezone by date_default_timezone_set() in my base file everything becomes ok. What do I wrong?
If you are facing problems in changing it via the php.ini file, you would be better off setting it via protected/config/main.php using 'timeZone' => 'UTC',in the returned array.
Should look something like this -
return array(
'timeZone' => 'UTC',
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
To do the same for the session cookie lifetime, add the following in the components array-
'components' => array(
...
'session' => array(
'cookieParams' => array(
'lifetime' => 300,
),
),
),

Categories