Re: Session with microtime
| From: | Jim Lucas | Date: | Thu, 19 Apr 2007 18:10:21 +0000 |
| Subject: | Re: Session with microtime | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-253277@lists.php.net to get a copy of this message | ||
Panquekas wrote:
hello, I'm writting a script where I use the function microtime with sessions and I have a problem. This is my code: if( $_SESSION['uperm'] == '1' ){ $t_start = microtime(1); } when you initially log in, it creates this variable.Sounds to me like it is creating the $_SESSION['uperm'] value after you are calling the previous if() {...} do this if ( $_SESSION['uperm'] == '1' ) { $t_start = microtime(1); die('I made it here'); } if it does not die(), then you know that it isn't getting into this first IF statement. also, sounds like you have E_WARNING & E_NOTICE turned off. I would suggest that you enable these by placing this at the very top of your script. ( at least for debugging purpose, not in production ) <?php error_reporting(E_ALL); ini_set('display_errors', 'On'); . . . ?> this will probably if you a notice not that the variable $t_start is undefined when try and hit the following block of code.
(....) if( $_SESSION['uperm'] == '1' ){ $t_end = microtime(1) - $t_start;-- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush$time .= "\n " . '<P>This page was loaded in ' .number_format($t_end, 3) . ' seconds.</P>'; } And when I log with any account (admin or user) is "echoed" to me something like this: "This page was loaded in 1,177,003,846.594 seconds." This is too much because the page isn't loaded in this time. And when I refresh the page it appears: "This page was loaded in 0.012 seconds." Why is this? I can't explain. And this started to appear when I put the "if" to check the user permissions. If I "turn off" the "if" it'll run normally. Can anyone explain why is that? Thanks in advance.