Time zone problem in Codeigniter - codeigniter

I have set the default time zone like date_default_timezone_set('America/New_York');
But the time is exactly 4 hrs advance.
(ie) if Current time is 6:00:00 then its saving as 10:00:00
Don't know whats wrong. Its working perfectly in localhost but not in godaddy server.

Have you tried asking godaddy? I'm fairly sure date_default_timezone_set is a native PHP function and not related explicitly to CodeIgniter:
http://php.net/manual/en/function.date-default-timezone-set.php

Related

Loading view from cache causes 500 internal server error when using Carbon\Carbon inside blade

I have a 4.2.17 version of laravel that was working perfectly fine for months. All of a sudden one of the views is returning a 500 server error, and is not logging anything into the storage/logs file (already checked all permissions).
I was able to manually track down the line causing the error and it turned out to be carbon\carbon that was causing the issue. For some reason it was crashing when I call Carbon:now() from a view. So I thought it might be carbon that was causing the issue or not loading properly.
However, Carbon:now() only crashes the app when it is being loaded from storage/cache.
If i go into storage/cache and delete everything and refresh, the page will work including the carbon line. Once i try and refresh a second time with files now in the cache folder, I will get the 500 server error.
If I remove all the carbon lines the page loads perfectly fine from cache.
This was all working perfectly before so I am not sure why it broke. Does anyone have any ideas? Is this an issue with loading from cache? Is there a better way I should be clearing it?
Thank you in advance for any help. Cheers.
Turned out to be a timeout issue, I guess loading from cache + carbon turned out to be too much for the server. Increasing max_execution_time did the trick.

Laravel Timezone UTC but got a London

I have a question
In Laravel config/app timezone = UTC
But my localhost is in Japan, `created_at time is London
I not sure that I have understood your question but... you are saying your locale config is UTC therefore you application runs with the correct configured timezone.
If you want to set a different timezone you should change it in config/app.php.
Check all available timezones in php: http://php.net/manual/es/timezones.php
Kind regards
You can set your timezone in laravel config/app like this
'timezone' => 'Asia/Tokyo'
This should solve your problem. With reference to http://php.net/manual/en/timezones.php
Regards.

Laravel log not showing system time

I seem to have a strange problem that I cant find and answer to.
When I run into any error in Laravel and I look at the log file, the time stanp shown in the log file is different from my system time.
Can someone help me fix this?
How can I update Laravel to show correct time?
Look at your app/config/app.php
There should be a field called timezone in which you could specify app-wide timezone, including your logs to match your system timezone.

codeigniter session data gets lost

i already posted this question but still wasnt able to resolve this issue.
seems that everyone has this problem with codeigniter .
When i set my session in a controller it works perfectly and i can display it.
WHen i move to another controller, the (CUSTOM) session data is completely lost.
i tried changing my cookie_domain in config.php. Since i am on localhost i tried localhost with without / and localhost/codeigniter and sodeigniter all did not work. i am lost
btw, i read somewhere that this happens when 2 ajax requests happen at the same time. could that be the problem?
Or maybe tell me how you resolved the problem if you had same issues
screw this, i am swithing to php native sessions. if anyone wants to do that,
http://codeigniter.com/wiki/PHPSession
Check and double-check your code or any external libraries you are using for a stray sess_destroy(). I ran into a similar problem where I was storing an id in the session for reference but if the user then logs in the SimpleLogin library I was using for logins just destroys the entire session including data I did not want to lose.
This is what I get for not writing my own code.

Zend framework session expires prematurely

I'm using Zend Framework for PHP and handling sessions with the Zend_Session module. This is what I have in my Initializer (or bootstrap):
Zend_Session::start();
Zend_Session::rememberMe(864000);
864000 seconds should be good for 10 days, but I'm still being kicked out at about an hour (or maybe a little less). I've tested to see if this statement works at all by setting it to 10 seconds, and indeed I am kicked out at the appropriate time, but when I set it to a very high value, it doesn't work! I went through some of the documentation here:
http://framework.zend.com/manual/en/zend.session.html
Another method I saw was to use the following:
$authSession = new Zend_Session_Namespace('Zend_Auth');
$authSession->setExpirationSeconds(3600);
Now, I have different namespaces. Does this mean I have to set this for all of them if I want to keep them from expiring? I haven't tested this method of setting the expiration, but I really wanted to see what the gurus on here had to say about what the correct way of approaching this problem is. Thanks a lot guys...
Also, does anyone know how I can make it so that the session never expires? I've tried setting the second to 0 and -1, but that throws an error.
I had the same problem and solved it by putting:
resources.session.save_path = APPLICATION_PATH "/../data/session/"
resources.session.gc_maxlifetime = 864000
resources.session.remember_me_seconds = 864000
in the application.ini (as suggested by tawfekov) and
protected function _initSessions() {
$this->bootstrap('session');
}
in the Bootstrap.php (this I typically forgot at first). You have to give the session directory the correct access rights (chmod 777). I described the issue here. Hopefully this will help the next person with the same issue.
Your client's computer clock, date, AND time zone need to be set correctly for session expirations to work. Otherwise the time conversions are off, and likely causing your cookie to expire the minute it hits the their browser.
Try calling remember me before starting the session:
Zend_Session::rememberMe(864000);
Zend_Session::start();
Otherwise I believe it will use the default of remember_me_seconds. See 49.4.4. rememberMe(integer $seconds)
Also, does anyone know how I can make
it so that the session never expires?
I've tried setting the second to 0 and
-1, but that throws an error.
I don't think that is possible. The session is controlled by whether the cookie exists on the users computer. Those cookies can be deleted, even by the users if they clear their cache. I think the best you can do is set it to a very large number. Say 12 months.
I guess you are using ZF 1.8 or above ,
so you can put in the config.ini file
resources.session.save_path = APPLICATION_PATH "/../data/session"
resources.session.remember_me_seconds = 864000
and these setting will automatically loaded
again only in ZF 1.8 or above if not you had to load these config manually
i hope it helps you :)
Are there other PHP applications running on the server?
Assuming you're using the standard, file-based, session handler, PHP will store all sessions in the same place (typically /tmp).
If you have some other script on the server using the default session_gc_maxlifetime settings, it may be eating your session files.
The easiest fix to try is to configure PHP to store session files for this application someplace special -- that way other apps running on the server will never accidently "clean up" session data from this app.
Try creating a directory like /tmp/myAppPhpSessions (or whatever), and adding:
ini_set('session.save_path','/tmp/myAppPhpSessions');
ini_set('session.gc_maxlifetime', 864000);
at the very top of your bootstrap file.
Make sure session.auto_start is off in php.ini

Resources