http://www.cnblogs.com/liushannet/archive/2010/08/19/1803209.html
Cookie使用:
<?php
echo Cookie::salt("abc
","def
");#得到保存到客户端的字符
#下面几个不解释~
echo Cookie::get("abc
");
Cookie::set("abc
","def
");
Cookie::delete
("abc
");
SESSION使用
类型有三个 (native,cookie,database)
默认是native(就是本地,PHP默认的)
其中database 配置
在APP的config里建立一个session.php文件
内容为:
<?php
return
array(
'database
' => array(
/**
* Database settings for session storage.
*
* string group configuation group name
* string table session table name
* integer gc number of requests before gc is invoked
* columns array custom column names
*/
'group
' => 'default
',
'table
' => 'sessions
',
'gc
' => 500,
'columns
' => array(
/**
* session_id: session identifier
* last_active: timestamp of the last activity
* contents: serialized session data
*/
'session_id
' => 'session_id
',
'last_active
' => 'last_active
',
'contents
' => 'contents
'
),
),
);
建立数据表:(和你配置的数据库配置有关系,下面描述)
CREATE TABLE `sessions` (
`session_id` VARCHAR( 24 ) NOT NULL,
`last_active` INT UNSIGNED NOT NULL,
`contents` TEXT NOT NULL,
PRIMARY KEY ( `session_id` ),
INDEX ( `last_active` )
) ENGINE = MYISAM ;
其中cookie 配置
<?
php
return
array
(
'cookie
' => array
(
'encrypted
' => FALSE,//设置为true需要配置encrypted
),
);
encrypted
配置
在相同目录下建立encrypt.php
<?
php
return
array
(
"default
"=>array
(
"key
"=>"dddd
",//你的密钥
"mode
"=>"ecb
",//加密方式,在PHP网站可以找到
"cipher
"=>MCRYPT_RIJNDAEL_128,//加密方式,在PHP网站可以找到
)
);
如果使用native就最方便啦,不用配置
在这里随便提下数据库配置吧
在同目录下建立
database.php
<?
php defined
('SYSPATH
') or die
('No direct access allowed.
');
return
array
(
'default
' => array
(
'type
' => 'pdo
',
'connection
' => array
(
/**
* The following options are available for PDO:
*
* string dsn Data Source Name
* string username database username
* string password database password
* boolean persistent use persistent connections?
*/
'dsn
' => 'mysql:host=localhost;dbname=****
',
'username
' => 'root
',
'password
' => '******
',
'persistent
' => FALSE,
),
/**
* The following extra options are available for PDO:
*
* string identifier set the escaping identifier
*/
'table_prefix
' => 'ko_
',
'charset
' => 'utf8
',
'caching
' => FALSE,
'profiling
' => TRUE,
),
);
以下是使用方式
<?
php
Session::instance("cookie
")->set("abc
","abcd
");
echo
Session::instance("cookie
")->get("abc
");
Session::instance("cookie
")->delete("abc
");
Session::instance("cookie
")->destroy();//清除SESSION
你可以把COOKIE去掉或者使用database试试,用database你会发现数据的sessions表会多一条记录
本地方式的话可以留空 即为:Session::instance();
修改Kohana_Session的$default为你想要的默认方式,除了在控制器头上设置不知道还有其他地方设置没,有点不方便,
在不修改它源代码的情况下~
分享到:
相关推荐
kohana是一个基于MVC模型构建的PHP5开发框架,它的目标旨在安全,重量轻,且易于使用。...*一个清洁的API和使用本土职能,尽可能使kohana成为最快的php5框架之一。 更加易用基于社区反馈提供可用的API和使用手册。
kohana是一个基于MVC模型构建的PHP5开发框架,它的目标旨在安全,重量轻,且易于使用。...*一个清洁的API和使用本土职能,尽可能使kohana成为最快的php5框架之一。 更加易用基于社区反馈提供可用的API和使用手册。
Kohana是PHP5的开发框架,基于MVC架构。MVC将应用逻辑分开,让我们的代码更加干净并且更快的找到bug。 ...它的主要特点如下:高安全性很轻巧容易学习使用MVC模式100%UTF-8编码松耦合结构易于扩展。
kohana3 用户手册kohana3 用户手册kohana3 用户手册
kohana一个php框架kohana一个php框架kohana一个php框架
kohana-3.2.2
kohana3.0 很不错的,想用它的必读
Kohana 3.0 Beginner's Guide(Jason D. Straughan) Develop professional web applications with Kohana 关于Kohana3的不可多得的资料。英文版,流畅易读。
Cookie 辅助函数 - 汉化度 98% 日期辅助函数 - 汉化度 100% 下载辅助函数 - 汉化度 100% Email 辅助函数 - 汉化度 100% Expires Helper - 汉化度 0% Feed 辅助函数 - 汉化度 100% 文件辅助函数 - 汉化度 100% 表单...
kohana3中文手册 百度上下载下来转换成pdf格式的。在这感谢翻译的人员不迟辛苦为中文人员的贡献。
kohana2.3.4帮助文档,稀缺资源,不可错过。官方已没有了。 中文汉化版。
很好的kohana教程本人已经看过非常好
kohana3.0 英文版,需要的可以下载
Kohana v2.2 中文手册.chm
kohana3.3.6官方最新稳定版本,kohana3.3.6官方最新稳定版本
Kohana中文手册,从菜鸟到高手的过程是艰辛的,你渴望救助。这本教程就是你无言的助手,默默的帮你到永远。 带奋斗一起飞翔,因为有了它,让我拥有理智之思;我才使过去的失误不再重演到今天的影片里;我才能使过去...
目前正在翻译当中,详情请关注 http://khnfans.cn http://khnfans.org.cn http://khnfans.com.cn
这是网上找的各种关于kohana的文档 自己动手进行了总结。
Kohana is an open source, object oriented MVC web framework built using PHP5 by a team of volunteers that aims to be swift, secure, and small. Kohana 3.0 英文 API 手冊
Kohana Docs v2.2.chm PHP框架chm学习资料