yii framework doesnt use the correct CSS - php

I'm working with yii framework I have installed the yii booster extensions and I work with vagrant. My friend also works on this project, however the problem is that the application doesn't use the correct CSS. Instead, it uses a CSS saved in cache.
Here how it is: There is a folder at: www\SVN\wwwroot\public\assets
it contains some folders with weird names, one of them contains all the bootstrap CSS and everything belonging to bootstrap. This is wrong because this art is regenerated every-time I regenerate vagrant. The problem is I am using the correct CSS unless I do a (delete cookie cash) sometimes I get the correct CSS sometimes I get the wrong CSS, but all the other people using this they get the wrong CSS, unless I change it for them manually on assests folder, which is totally wrong because every time I update my workstation using svn it should apply the new lay out to other prople as well but it doesn't work.
Here is my main config:
<?php
/**
* This is the main Web application configuration.
*
* Any writable CWebApplication properties can be configured here.
* It is constructed the following way:
* main.php = return the main settings
* unless overwritten by the local main settings if available
* unless overwritten by the test settings if available
* unless overwritten by the local test settings if available
* (mergeArray: latter will overwrite the former, see http://www.yiiframework.com/doc/api/1.1/CMap#mergeArray-detail)
*
* #author Yii, adapted by Robbert <Paulussen#Momentum-Technologies.nl>
* #since release 1.0 (sprint 1)
*/
// Set up path variables to reflect the directory structure
// $WEBHOME/ -- doePath // = wwwroot
// $WEBHOME/public/ -- webrootPath
// $WEBHOME/private/protected/ -- protectedPath
// $WEBHOME/private/runtime/ -- runtimePath
$pathToDoeDirectory = realpath(dirname(__FILE__) . '/../../..'); // = wwwroot
$privatePath = $pathToDoeDirectory . '/private/';
$protectedPath = $pathToDoeDirectory . '/private/protected/';
$runtimePath = $pathToDoeDirectory . '/private/runtime/';
$publicPath = $pathToDoeDirectory . '/public/';
$webrootPath = $publicPath;
$vendorPath = '/vagrant/vendor/';
/**
* Namespace MTE
*/
Yii::setPathOfAlias('MTE', $protectedPath);
// used by the themeUrl of widgetFactory settings, in case the DOE is in a subdirectory
$baseUrl = (isset($_SERVER['DOCUMENT_ROOT'])) ? str_replace($_SERVER['DOCUMENT_ROOT'], '', realpath('.')) : '';
//define('EOL','<br/>');
//echo '$pathToCcsDirectory = ' . $pathToCcsDirectory . PHP_EOL;
//echo '$privatePath = ' . $privatePath . PHP_EOL;
//echo '$protectedPath = ' . $protectedPath . PHP_EOL;
//echo '$runtimePath = ' . $runtimePath . PHP_EOL;
//echo '$publicPath = ' . $publicPath . PHP_EOL;
//echo '$webrootPath = ' . $webrootPath . PHP_EOL;
/** the following defines path aliases using: Yii::setPathOfAlias('local','path/to/local-folder');
* usage e.g. ... Yii::getPathOfAlias('runtimePath') ...
*/
Yii::setPathOfAlias('doePath', $pathToDoeDirectory);
Yii::setPathOfAlias('privatePath', $privatePath);
Yii::setPathOfAlias('publicPath', $publicPath);
Yii::setPathOfAlias('protectedPath', $protectedPath);
Yii::setPathOfAlias('runtimePath', $runtimePath);
Yii::setPathOfAlias('webrootPath', $webrootPath);
Yii::setPathOfAlias('vendorPath', $vendorPath);
Yii::setPathOfAlias('booster', $vendorPath . 'clevertech/yii-booster/src/'); // a twitter bootstrap library
//Yii::setPathOfAlias('booster', $publicPath . 'css/yii-booster/src/'); // a twitter bootstrap library
$config_database = require(dirname(__FILE__) . '/database.php');
$config_main = array(
'sourceLanguage' => 'en', // for i18N
'timeZone' => 'Europe/Amsterdam',
'basePath' => $protectedPath,
// override the default of Yii
'runtimePath' => $runtimePath,
'name' => Yii::t('systemwide', 'DOEN - DOssier opvolg- EN actiesysteem'),
//'theme'=>'bootstrap',
'preload' => array(
'log',
'translate', // for i18N
'booster', //Yii-Booster, a twitter bootstrap library
),
'behaviors' => array(
'onBeginRequest' => array(
'class' => 'application.components.modulesloader',),
), // for i18N
// autoloading model and component classes, Note that importing a directory does not import any of its subdirectories!
'import' => array(
'application.components.*',
'application.models.*',
'application.modules.rights.*',
'application.modules.rights.components.*',
'application.modules.translate.TranslateModule',
'booster.helpers.TbHtml',
'booster.helpers.TbArray',
'booster.behaviors.TbWidget',
'booster.widgets.*'
),
'modules' => array(
'rights' => array(
'install' => false, // Whether to install rights.
'userNameColumn' => 'login', // Name of the user name column in the database.
'userClass' => 'RightsModuleUser', // extended User model
'cssFile' => '/MTE/modules/rights/default.css', // custom css for rights module
'superuserName' => 'MTeAdmin', // doe_user.login of the user with super user privileges. Default 'Admin'
/* more options */
// 'appLayout' => 'application.views.layouts.main', // Application layout.
// 'authenticatedName' => 'Authenticated', // Name of the authenticated user role.
// 'baseUrl' => '/rights', // Base URL for Rights. Change if module is nested.
// 'debug' => false, // Whether to enable debug mode.
// 'displayDescription' => true, // Whether to use item description instead of name.
// 'enableBizRule' => true, // Whether to enable authorization item business rules.
// 'enableBizRuleData' => false, // Whether to enable data for business rules.
// 'flashErrorKey' => 'RightsError', // Key to use for setting error flash messages.
// 'flashSuccessKey' => 'RightsSuccess', // Key to use for setting success flash messages.
// 'layout' => 'rights.views.layouts.main', // Layout to use for displaying Rights.
// 'userIdColumn' => 'id', // Name of the user id column in the database.
),
'translate',
'components' => array(
//use component to store the cookies
'Cookies' => array(
'class' => 'application.components.CookiesHelper'
),
// uncomment the following to enable URLs in path-format
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
'errorHandler' => array(
// use 'site/error' action to display errors
'errorAction' => 'site/error',
),
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
array(
'class' => 'CFileLogRoute',
'levels' => 'info, warning, error',
),
),
),
),
),
// application components
'components' => array(
// this class is used to simplify template actions
'TemplateHelper' => array(
'class' => 'application.components.TemplateHelper',
),
/* i18N - begin */
'messages' => array(
'class' => 'CDbMessageSource',
'onMissingTranslation' => array('TranslateModule',
'missingTranslation',
),
),
'translate' => array(
'class' => 'translate.components.MPTranslate',
'acceptedLanguages' => array(
'en' => 'English',
'nl' => 'Nederlands',
),
),
/* i18N - end */
'authManager' => array(
'class' => 'RDbAuthManager',
'connectionID' => 'db',
'defaultRoles' => array('authenticated', 'user'),
),
'user' => array(
'class' => 'WebUser',
/* enable cookie-based authentication */
'allowAutoLogin' => true,
/* #see http://www.yiiframework.com/doc/guide/1.1/en/topics.auth */
'loginUrl' => array('/site/login'),
),
'booster' => array(
'class' => 'booster.components.Bootstrap',
'coreCss' => true,
'responsiveCss' => true,
'yiiCss' => true,
'minify' => true,
),
),
/** application-level parameters that can be accessed
* using Yii::app()->params['paramName']
*/
'params' => array(
// this is used in contact page
'adminEmail' => 'beheer#momentum-technologies.nl',
'cookie_duration' => 3600 * 24 * 30,
'composer.callbacks' => array(
// args for Yii command runner
'yiisoft/yii-install' => array('yiic', 'webapp', dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'),
'post-update' => array('yiic', 'migrate'),
'post-install' => array('yiic', 'migrate'),
),
),
);
$mainDbIncluded = CMap::mergeArray($config_database, $config_main);
// include and merge local main config if it exists
if (file_exists(dirname(__FILE__) . '/main-local.php'))
{
return CMap::mergeArray($mainDbIncluded, include(dirname(__FILE__) . '/main-local.php'));
}
// otherwise just load the main config file
return $mainDbIncluded;
As you can see I have defined my CSS path to be:
Yii::setPathOfAlias('booster', $vendorPath . 'clevertech/yii-booster/src/'); // a twitter bootstrap library
here is my header.php that goe wrong:
<?php
$lang = Yii::app()->getLanguage();
if (empty($lang))
{
$lang = 'en';
}
?>
<!DOCTYPE html>
<html lang="<?php echo $lang; ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/widgets/jui.tabs.css" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->baseUrl; ?>/css/common.css" />
<?php
Yii::app()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/common.js');
?>
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/widgets/jui.tabs.css" />
</head>
<body>
<div id="header">
<?php
$this->widget('booster.widgets.TbNavbar', array(
'brand' => '<img src="' . Yii::app()->request->baseUrl . '/images/logo_mte.png" alt="" />' ,
'brandUrl' => '#',
'collapse' => true,
'type' => null,
'items' => array(
'brand' => Yii::App()->name ,
array(
'class' => 'booster.widgets.TbMenu',
'items' => array(
array('label' => 'Login', 'url' => array('/site/login'), 'visible' => Yii::app()->user->isGuest),
array('label' => 'Logout (' . Yii::app()->user->name . ')', 'url' => array('/site/logout'), 'visible' => !Yii::app()->user->isGuest)
),
),
)));
?>
</div>
<div id="ajaxLoading">
<!--<img src="../public/images/ajax-loader.gif" alt="Loading..."/>-->
</div>
an when I look at my inspect element in chrome this is what I see:
as you can see it is generated in assets. but I dont want it to be like this how can I fix that?
But it doesn't use this one and instead, it uses an incorrect version. Can someone help me out with this? Maybe I am getting this wrong and the problem is from something else. Thanks

I experienced many CSS issues when working with the Booster extension before, re-installing it following those steps fixed them for me at that time:
Get YiiBoilerplate
and unzip it somewhere, it's created by the same guys at clevertech
and using the booster extension by default.
Go to {unzipped}backend/views/layouts/ and grab main.php,
column1.php and column2.php
create a new theme in your webapp under the /themes folder (I called
it 'booster')
Copy the three files from (3) into themes/booster/views/layouts In
your main.php add 'theme' => 'booster' as a top-level entry of the
array (I put it first)
That was #TeacherT solution that worked out for me after posting this Stackoverflow question, other solutions has came out later and seemed to solve the CSS issues to other users, so you may try them too.

Related

Zend - static and dynamic route

How should I prepare my routes to deal with it, instead of addictional parts in url?
$routes = array(
/**
* Static
*/
'news' => new Zend_Controller_Router_Route('news/:page',
array('controller' => 'news', 'action' => 'index', 'page' => 1 )
),
/**
* Dynamic
*/
'thread' => new Zend_Controller_Router_Route(':slug/:page',
array('controller' => 'Thread', 'action' => 'index', 'page' => 1 )
),
e.g. example.com/thread-name-slug it shows thread with slug thread-name-slug but when I visit example.com/news it wants to show thread with slug news. I want static page here.
Thanks in advance.
The router matches routes in reverse order of their declaration. Given the request url /news, the router will attempt to match first against the route :slug/:page and, of course, finds a match, so it never gets to examine your news/:page route.
The solution is to reverse the order in which you declare the routes. Generally speaking, one wants to add generic routes before specific ones.
As the latest version of zendframework is 3.x I'll post a sample solution for Zf3, because it's not easy a complete article on zend routes.
Supouse you wanna centralize your admin requests by using only one controller; so you can check permisions, roles, etc in order to serve your site's admin pages.
We'll perform the next tasks:
Edit the "module.config.php" file to have a easy to read code.
Create a DefineRoutes.php file
Write a simple regular expression to set wildcard matching places for all posible admin tasks.
I'll supouse we creates an admin module properly registered in "modules.config.php" file
Editing the module.config.php file:
<?php
/**
* #Filename: zendframework/module/Admin/config/module.config.php
* The module required settings.
* #author: your name here
*/
return [
'controllers' => [
'factories' => include __DIR__ . '/ControllerFactories.php'
],
'router' => [
'routes' => include __DIR__ . '/DefineRoutes.php',
],
'view_manager' => ['template_path_stack' => [__DIR__ . '/../view',],],
];
Note: we do not use the close tag ?> in our files
Creating the "DefineRoutes.php" file.
<?php
/**
* #Filename: zendframework/module/Admin/config/DefineRoutes.php
* Declares site's admin routes
* #author: your name here
*/
namespace Admin;
use Zend\Router\Http\Segment;
// first a couple of useful functions to make our life easy:
// Creates a regexp to match all case-variants of a word
function freeCaseExt($toCase){
$len = strlen($toCase);
$out = '';
if($len < 1){ return $out; }
for ($i=0; $i<$len; $i++){
$s = strtolower(substr($toCase, $i, 1));
$out .= '['.$s.strtoupper($s).']';
}
return $out;
}
// To append slash child routes elsewhere
function SlashUri($controller, $action){
return [
'type' => \Zend\Router\Http\Literal::class,
'options' => [
'route' => '/',
'defaults' => ['controller' => $controller, 'action' => $action ]]];
}
$adminvariants = freeCaseExt('admin'); // to constrain our main route
// Our route family tree:
'admin' => [
'type' => Segment::class,
'options' => [
'route' => '/:admin[/:case][/:casea][/:caseb][/:casec][/:cased][/:casee][/:casef][/:caseg][/:caseh]',
'constraints' => [
'admin' => $adminvariants,
'case' => '[a-zA-Z0-9][a-zA-Z0-9_-]*',
'casea' => '[a-zA-Z0-9][a-zA-Z0-9_-]*',
'caseb' => '[a-zA-Z0-9][a-zA-Z0-9_-]*',
'casec' => '[a-zA-Z0-9][a-zA-Z0-9_-]*',
'cased' => '[a-zA-Z0-9][a-zA-Z0-9_-]*',
'casee' => '[a-zA-Z0-9][a-zA-Z0-9_-]*',
'casef' => '[a-zA-Z0-9][a-zA-Z0-9_-]*',
'caseg' => '[a-zA-Z0-9][a-zA-Z0-9_-]*',
'caseh' => '[a-zA-Z0-9][a-zA-Z0-9_-]*'
],
'defaults' => [
'controller' => Controller\AdminController::class,
'action' => 'index'
]
],
'may_terminate' => TRUE,
'child_routes' => [
'adminslash' => SlashUri(Controller\AdminController::class, 'index'),
]
],
// Now you have declared all the posible admin routes with or without
// slaches '/' at 9 deep levels using the AdminController::Index() method
// to decide wath to do.
IMPORTANT: As we defined a first level wildcard :admin a proper constraint is required or it overlaps other first level routes.
The controllers logics is a few out of skope.
Hope this idea helps somebody.
Luis

Yii HumHub Inject Event into Main App

I am trying to attach a event to a global scope of a Yii application called HumHub however, when I try to run a function through the "TopMenu" which is global, it doesn't appear to do anything. Possibly because I'm not using the $event variable scope?
I am trying to make a development mode module to prevent access to anyone but administrators from viewing the system when it's activated. The only global way I know to get my code across all pages (with my limited understanding of HumHub and Yii) is the TopMenu as it appears on all pages (besides login page which is disabled when guest mode is active)
autostart.php
Yii::app()->moduleManager->register(array(
'id' => 'devmode',
'class' => 'application.modules.devmode.DevModeModule',
'import' => array(
'application.modules.devmode.*',
),
// Events to Catch
'events' => array(
array('class' => 'AdminMenuWidget', 'event' => 'onInit', 'callback' => array('DevModeEvents', 'onAdminMenuInit')),
array('class' => 'TopMenuWidget', 'event' => 'onInit', 'callback' => array('DevModeEvents', 'devBlock')),
array('class' => 'DashboardSidebarWidget', 'event' => 'onInit', 'callback' => array('DevModeModule', 'onSidebarInit')),
),
));
DevModeEvents.php
<?php
/**
* Defines the module events
*
* #package humhub.modules.devmode.events
* #author Jordan Thompson
*/
class DevModeEvents {
public static function onAdminMenuInit($event)
{
$event->sender->addItem(array(
'label' => Yii::t('devmode.base', 'Development Mode'),
'url' => Yii::app()->createUrl('//devmode/config/config'),
'group' => 'settings',
'icon' => '<i class="fa fa-lock"></i>',
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'devmode' && Yii::app()->controller->id == 'admin'),
'sortOrder' => 300,
));
}
public static function devBlock($event) {
$devMode = HSetting::Get('devMode', 'devmode');
if ($devMode == 1 ) {
if (!Yii::app()->user->isGuest) {
if (!Yii::app()->user->isAdmin()) {
throw new CHttpException('418', Yii::t('devmode.base', Yii::app()->name . ' is currently under maintenance, check back later.'));
}
} else {
throw new CHttpException('418', Yii::t('devmode.base', Yii::app()->name . ' is currently under maintenance, check back later.'));
}
}
}
}
change the sort order to 1, and access to it using css
li:nth-child(1) {
//do something;
}

ZF2 validator messages i18n

I localize product, and i'm newb in PHP,ZF2. I have .PO/.MO files with english and japanese translation. How to configure ZF2 to use these .mo translation in all library\Zend\Validator\* files instead of default messages e.g
protected $messageTemplates = array(
self::NOT_GREATER => "The input is not greater than '%min%'",
self::NOT_GREATER_INCLUSIVE => "The input is not greater or equal than '%min%'"
);
I've read these link but it doesnt help me.
I'm have custom Translator which extends MvcTranslator and config looks like:
```
),
'service_manager' => array(
'aliases' => array(
'translator' => 'MvcTranslator',
),
'factories' => array(
// ...
'MvcTranslator' => function ($services) {
$config = $services->get('config');
$config = isset($config['translator']) ? $config['translator'] : array();
$translator = \Application\I18n\Translator::factory($config);
$translator->setEscaper(new \Application\Escaper\Escaper);
// add event listener for context fallback on missing translations
$translator->enableEventManager();
$translator->getEventManager()->attach(
$translator::EVENT_MISSING_TRANSLATION,
array($translator, 'handleMissingTranslation')
);
// establish default locale settings
$translator->setLocale($translator->getLocale() ?: 'en_US');
$translator->setFallbackLocale($translator->getFallbackLocale() ?: 'en_US');
// try to guess locale from browser language header (using intl if available)
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])
&& (!isset($config['detect_locale']) || $config['detect_locale'] !== false)
) {
$locale = extension_loaded('intl')
? \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE'])
: str_replace('-', '_', current(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'])));
$translator->setLocale(strlen($locale) ? $locale : $translator->getLocale());
}
return $translator;
},
),
),
'translator' => array(
'locale' => 'en_US',
'detect_locale' => true,
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo'
),
),
),
```
I thought i should put Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
somewhere there..but nothing changed..Should i write some code in validators or what ?

Zend2 navigation

I would like to make navigation buttons in my view, for example index.phtml but it's not working. I did know how to do it in Zend1 but in Zend2 I have a problem. My code looks like this (file index.phtml):
$container = new \Zend\Navigation\Navigation($tableActions);
var_dump($container);
echo '<div class="table-column">';
echo $this->navigation($container)->menu();
echo '</div>';
Variable $tableAction looks like this:
public $tableActions = array(
array(
'label' => 'On/Off',
'module' => 'import',
'controller' => 'import',
'action' => 'setstatus',
'params' => array('id' => null),
),
);
I did not get any error, just whole site die on this line. var_dump returns object(Zend\Navigation\Navigation) so it's fine so far. Problem is, how to show it...
The navigation pages have dependencies which aren't being met by just creating a new container class in a view. The Mvc page needs a RouteStackInterface (Router) instance and a RouteMatch instance. Similarly Uri pages need the current Request instance.
You can see this clearly if you take a look at the Zend\Navigation\Service\AbstractNavigationFactory and its preparePages and injectComponents methods.
The view is not the right place to be instantiating menus, instead put the menu configuration spec in your module.config.php...
<?php
return array(
'navigation' => array(
'table_actions' => array(
array(
'label' => 'On/Off',
'module' => 'import',
'controller' => 'import',
'action' => 'setstatus',
'params' => array('id' => null),
),
),
),
);
Write a factory extending the AbstractNavigationFactory class and implement the getName() method which returns the name of your menu spec key (table_actions in this example)
<?php
namespace Application\Navigation\Service;
use Zend\Navigation\Service\AbstractNavigationFactory;
class TableActionsFactory extends AbstractNavigationFactory
{
/**
* #return string
*/
protected function getName()
{
return 'table_actions';
}
}
Map the factory to a service name in the service_manager spec of module.config.php ...
<?php
return array(
'navigation' => array(// as above ... )
'service_manager' => array(
'factories' => array(
'TableActionsMenu' => 'Application\Navigation\Service\TableActionsFactory',
),
),
);
Now you can call the view helper using the service name TableActionsMenu you just mapped
<div class="table-column">
<?php echo $this->navigation('TableActionsMenu')->menu(); ?>
</div>
Finally, if, as I suspect, you need to change an attribute of the page depending on the view, you can do that too, navigation containers have find* methods which can be accessed from the navigation helper and used to retrieve pages.
Here's an example looking for the page with a matching page label, then changing it before rendering (obviously not an ideal search param, but it gives you the idea)
$page = $this->navigation('TableActionsMenu')->findOneByLabel('On/Off');
$page->setLabel('Off/On');
// and then render ...
echo $this->navigation('TableActionsMenu')->menu();

Session timeout not working for CHttpSession in Yii framework

I am creating an web application in Yii . I was trying to do a sessiontimeout, if a user is idle for 30 minutes.After that he should login again.. but this is not working. I am using CHttpSession. However if i give CDbHttpSession instead of CHttpSession this is working fine.
this is my code
'user' => array(
'class' => 'WebUser',
'loginUrl' => array('site/loginaccount'),
'allowAutoLogin' => true,
),
// uncomment the following to enable URLs in path-format
'session' => array(
'class'=>'CHttpSession',
'timeout'=>$params['session_timeout'],
'autoStart'=>true,
),
Is there anything else to make this work for CHttpSession ? Due to some reasons i cannot use CDbHttpSession in my web application .
If you want that the user is sign out automatically after 30 minutes try:
'user' => array(
'class' => 'WebUser',
'loginUrl' => array('site/loginaccount'),
'allowAutoLogin' => true,
'authTimeout' => 1800
),
protected/config/main.php : (define the session timeout)
$sessionTimeout = 5; // 5 secondes
return array(
'params'=>array(
'session_timeout'=> $sessionTimeout,
);
'components'=>array(
'session' => array(
'class' => 'CDbHttpSession',
'timeout' => $sessionTimeout,
),
),
);
protected/views/layout/main.php : (define the refresh)
<html>
<head>
<?php if (!Yii::app()->user->isGuest) {?>
<meta http-equiv="refresh" content="<?php echo Yii::app()->params['session_timeout'];?>;"/>
<?php }?>
</head>
<body>
…
</body>
</html>
I've read the source code of the CHttpSession. It is a wrap of the PHP Session. So, the mechanism of CHttpSession is the same with the PHP Session.
public function setTimeout($value)
{
ini_set('session.gc_maxlifetime',$value);
}
the above is the code of timeout setter. it is just the setting of ini settings of the PHP. And according to the PHP documentation of session, after the maxlifetime, the session is just "potentially cleaned up", not for sure.
And the probability of it can be set by session.gc_probability. the default value is 1, which means 1%. So, you can set it to 100, make the garbage collection process run every time the script is run.
change your setting to
'session' => array(
'class'=>'CHttpSession',
'timeout'=>$params['session_timeout'],
'autoStart'=>true,
'gCProbability' => 100,
),
hope it helps.
return array('components'=>array(
'session'=>array(
'timeout' => 1800
),
),
);

Categories