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,
),
),
),
Related
In my service provider boot() I have the following:
config([
'app.name' => 'Elephant',
'app.url' => 'http://elephant.dev',
'app.timezone' => 'America/Toronto',
]);
app.name and app.url both work fine, but app.timezone does not work. My configuration is NOT cached.
I'm saying it does not work because when I create() a record in the database, it is still using UTC for the created_at column and not America/Toronto.
Why is this happening and how to I make it work?
Make an environment variable in .env file
APP_TIMEZONE='America/Toronto'
and then in config/app.php set timezone to this
'timezone' => env('APP_TIMEZONE', 'UTC'),
If this is not solving the problem then just post in comment and I will delete the answer.
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',
In my application I want to use session and cookies. On reading about session I came to know that in two ways I can implement session one is by session management and one is by using containers, using containers seems to be easy. I want to know which one is better or both are same and I am missing something. I want to use session and cookies both, can anyone have some source code or coding examples where session and cookies both have been used ? I don't know how to send the cookies to get the session values and how to use these values in my view files(js and phtml). Following is the code for session manager reffered from zend documentation:
return array(
'session' => array(
'config' => array(
'class' => 'Zend\Session\Config\SessionConfig',
'options' => array(
'name' => 'myapp',
),
),
'storage' => 'Zend\Session\Storage\SessionArrayStorage',
'validators' => array(
'Zend\Session\Validator\RemoteAddr',
'Zend\Session\Validator\HttpUserAgent',
),
),
);
Do I need to place this code in my application.config.php file?
Session Container used for working with session DATA.
Session Manager used for work with session LOGIC (e.g. start/close).
Do I need to place this code in my application.config.php file?
Yes, in ZF2 docs wroted:
The following illustrates how you may configure session manager by setting options in your local or global config:
Working with Yii framework 2.0 I get records from my database. In each table I have a column named created_at. Let's say created_at = '2015-12-25 01:00:00'. I use the following Yii formatter.
Yii::$app->formatter->asDate($model->created, 'php:d-m-Y h:i:s');
The result is: 25-12-2015 02:00:00. It is 1 hour earlier. I don't know why. What should I configure to fix this?
#Soju: I have tried your solution. I needed to change your answer a little bit since it solves the problem with the following configuration.
'components' => [
'formatter' => [
'defaultTimeZone' => 'Europe/Paris',
],
],
You should set formatter defaultTimeZone and timeZone in your components config, for example if you store UTC in your database and want to display Europe/Paris :
'components' => [
'formatter' => [
'defaultTimeZone' => 'UTC',
'timeZone' => 'Europe/Paris',
],
],
Read more : http://www.yiiframework.com/doc-2.0/guide-output-formatter.html#time-zones
I am having trouble getting Zend to store my session in MySQL table. I have followed the Zend Framework guide step by step, and am not sure if is where am putting the code in my bootstrap file, but once the code snippet is in place and I load my site Apache just crashes. Literally crashes. My logs don't say anyhing.
Here is my code:
$db = Zend_Db::factory( 'Pdo_Mysql', array(
'host' => 'localhost',
'username' => 'root',
'password' => '*****',
'dbname' => 'drecords'
));
Zend_Db_Table_Abstract::setDefaultAdapter( $db );
$config = array(
'name' => 'sessions',
'primary' => 'id',
'modifiedColumn' => 'modified',
'dataColumn' => 'data',
'lifetimeColumn' => 'lifetime'
);
Zend_Session::setSaveHandler( new Zend_Session_SaveHandler_DbTable( $config ) );
//start your session!
Zend_Session::start();
I am running this code right after at the end of my Bootstrap file.
My question is what am I doing wrong if am following Zends documentation? Is there something I need to know like an extra configuration option in my MySQL or PHP.ini that am not aware of?
Did you create the table in MySQL?
your user have insert/update/delete privileges on the table
do your php setups output errors, what environment are your running production/development
I think the code should probably output some error but if your disabled the output of those you cannot see them.