YII 多點登陸配置講解

配置文件的種域名必須是連接域名或者子域名,否則不能生成sessionId.
session使用memcached時,先檢查memcached是否在運行,然後如果不能訪問再開文件中的id配置每個項目的配置文件應該一致ID,詳細配置:

<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'id'=>'id.6255.cn',//不同的項目子域名相同的多站點項目,id必須一致否則拿不到memcached的值
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Web Application',

// preloading 'log' component
'preload'=>array('log'),

// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),

'modules'=>array(
// uncomment the following to enable the Gii tool
/*
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'Enter Your Password Here',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
*/
),

// application components
'components'=>array(

'user'=>array(
// enable cookie-based authentication
'class' => 'XWebUser',//多個項目的類名必須一致但是內容可以不一致
'identityCookie'=>array('domain' => '.6255.com'),//這個domain必須與上下文一致
'allowAutoLogin'=>true,
),

// uncomment the following to enable URLs in path-format
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
*/

// database settings are configured in database.php
'db'=>require(dirname(__FILE__).'/database.php'),

'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>YII_DEBUG ? null : 'site/error',
),
'session'=>array(
'class'=> 'CCacheHttpSession',
'sessionName'=>'PHPSESSID',
//'autoStart' => true,
'cacheID' => 'sessionCache',//we only use the sessionCache to store the session
'cookieMode' => 'allow',
'cookieParams' => array(
'path' => '/',
'domain'=>'.6255.com',//這個參數必須是鏈接中的域名或者子域名否則不能生成session_id
'httpOnly' => true,
)
),
'sessionCache'=>array(
'class'=>'system.caching.CMemCache',
'servers'=>array(
array('host'=>'192.168.182.128', 'port'=>11211)
),
'useMemcached' => false ,
),
'securityManager' => array(
'validationKey' => '6255Security',
'encryptionKey' => '6255Encryption',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),

),

// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'[email protected]',
),
);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章