本文整理汇总了PHP中CakeSession::write方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeSession::write方法的具体用法?PHP CakeSession::write怎么用?PHP CakeSession::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeSession
的用法示例。
在下文中一共展示了CakeSession::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postLogin
public function postLogin()
{
$this->loadModel('User');
$key = 'iznWsaal5lKhOKu4f7f0YagKW81ClEBXqVuTjrFovrXXtOggrqHdDJqkGXsQpHf';
$email = trim($this->request->data['email']);
$password = trim($this->request->data['password']);
$encrypted_password = Security::cipher($password, $key);
$opts = array('conditions' => array('and' => array('User.user_email' => $email, 'User.password' => $encrypted_password)));
$userInfo = $this->User->find('first', $opts);
if ($userInfo) {
//session
CakeSession::write('session_id', $userInfo['User']['user_id']);
CakeSession::write('session_name', $userInfo['User']['user_name']);
CakeSession::write('session_email', $userInfo['User']['user_email']);
$this->redirect('../User/user_profile');
} else {
$this->loadModel('CreateGroup');
$opts = array('conditions' => array('and' => array('CreateGroup.group_admin_email' => $email, 'CreateGroup.password' => $encrypted_password)));
$groupInfo = $this->CreateGroup->find('first', $opts);
if ($groupInfo) {
//session
CakeSession::write('session_id', $groupInfo['CreateGroup']['group_id']);
CakeSession::write('session_name', $groupInfo['CreateGroup']['group_name']);
CakeSession::write('session_code', $groupInfo['CreateGroup']['group_code']);
CakeSession::write('session_email', $groupInfo['CreateGroup']['group_admin_email']);
$this->redirect('../Admin/group_profile');
} else {
$this->Session->write('login_message', 'Invalid username or password');
$this->redirect('../login/home');
}
}
}
示例2: login
public function login()
{
//echo hash('sha512', 'TransF0rm3rs');
if ($this->request->is('post')) {
$username = stripslashes($this->request->data['username']);
$password = stripslashes(hash('sha512', stripslashes($this->request->data['password'])));
$conditions = array('conditions' => array('username' => $username, 'password' => $password));
$admin = $this->Admin->find('all', $conditions);
if (count($admin) > 0) {
// admin user found;
$this->Session->setFlash(__('Yay! You have been logged in.'));
CakeSession::write('admin_user', $admin);
$this->redirect('/admin/reports');
} else {
$this->loadModel('AffiliateMember');
$this->AffiliateMember->recursive = 2;
$admin = $this->AffiliateMember->find('all');
if (count($admin) > 0) {
$this->Session->setFlash(__('Yay! You have been logged in.'));
CakeSession::write('admin_user', $admin);
$this->redirect('/admin/reports');
} else {
$this->Session->setFlash(__('Oops! The user account could not be found.'));
}
}
}
}
示例3: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->controller);
Configure::write('Config.language', null);
CakeSession::write('Auth.User', null);
parent::tearDown();
}
示例4: authenticate
/**
* Authenticates the identity contained in a request. Will use the `settings.userModel`, and `settings.fields`
* to find POST data that is used to find a matching record in the `settings.userModel`. Will return false if
* there is no post data, either username or password is missing, of if the scope conditions have not been met.
*
* @param CakeRequest $request The request that contains login information.
* @param CakeResponse $response Unused response object.
* @return mixed. False on login failure. An array of User data on success.
*/
public function authenticate(CakeRequest $request, CakeResponse $response)
{
$userModel = $this->settings['userModel'];
list($plugin, $model) = pluginSplit($userModel);
if (empty($request->data[$model])) {
return false;
}
if (empty($request->data[$model][$this->settings['post_key']]) || empty($request->data[$model][$this->settings['fields']['password']])) {
return false;
}
$User = ClassRegistry::init($userModel);
$password = $request->data[$model][$this->settings['fields']['password']];
foreach ($this->settings['fields']['username'] as $username) {
$conditions = array();
if (!empty($this->settings['scope'])) {
$conditions = array_merge($conditions, $this->settings['scope']);
}
$conditions[$model . '.' . $username] = $request->data[$model][$this->settings['post_key']];
$conditions[$model . '.' . $this->settings['fields']['password']] = $this->_password($password);
$result = $User->find('first', array('conditions' => $conditions, 'contain' => $this->settings['contain']));
if (!empty($result) || !empty($result[$model])) {
CakeSession::write(Configure::read('SessionKey'), $result);
unset($result[$model][$this->settings['fields']['password']]);
return $result[$model];
}
}
return false;
}
示例5: tearDown
/**
* tearDown
*
* @return void
*/
public function tearDown()
{
Configure::write('Config.language', null);
CakeSession::write('Auth.User', null);
unset($this->Questionnaire);
parent::tearDown();
}
示例6: testSaveConvertVideoMp4Exception
/**
* 動画変換とデータ保存 MP4例外テスト
*
* @return void
* @throws Exception
*/
public function testSaveConvertVideoMp4Exception()
{
// 暫定対応(;'∀') ffmpeg未インストールによる travis-ci error のため、コメントアウト
//$this->setExpectedException('InternalErrorException');
// AuthComponent::user('id');対応
$Session = new CakeSession();
$Session->write('Auth.User.id', 1);
$data = array('Video' => array('block_id' => 2));
$video = array('Video' => array('mp4_id' => 1), Video::VIDEO_FILE_FIELD => array('FilesPlugin' => array('plugin_key' => 'videos')));
$roomId = 1;
// テストファイル準備
$contentsId = $video['Video']['mp4_id'];
$fileName = 'video1.mp4';
$this->_readyTestFile($contentsId, $roomId, $fileName);
// 例外を発生させるためのモック
$videoMock = $this->getMockForModel('Videos.Video', ['save']);
$videoMock->expects($this->any())->method('save')->will($this->returnValue(false));
$videoMock->FileModel = ClassRegistry::init('Files.FileModel');
try {
// 動画変換とデータ保存
$videoMock->saveConvertVideo($data, $video, $roomId);
} catch (Exception $e) {
// テストファイル削除
$this->_deleteTestFile();
// 暫定対応(;'∀') ffmpeg未インストールによる travis-ci error のため、コメントアウト
//throw $e;
}
}
示例7: postLogin
public function postLogin()
{
$this->loadModel('User');
//admin send request to user with its url parameter group_id and random_no
$group_id = trim($this->request->data['group_id']);
$random_no = trim($this->request->data['random_no']);
$email = trim($this->request->data['email']);
$password = base64_encode(trim($this->request->data['password']));
$opts = array('conditions' => array('and' => array('User.txt_email' => $email, 'User.txt_pswd' => $password)));
$userInfo = $this->User->find('first', $opts);
if ($userInfo) {
CakeLog::write('info', '.....Login successfully...');
//session
CakeSession::write('session_id', $userInfo['User']['nbr_user_id']);
CakeSession::write('session_name', $userInfo['User']['txt_name']);
CakeSession::write('session_email', $userInfo['User']['txt_email']);
CakeLog::write('info', ' Session values are Session User Id : ' . $userInfo['User']['nbr_user_id'] . ' Session User Name : ' . $userInfo['User']['txt_name'] . ' Session User Email : ' . $userInfo['User']['txt_email']);
//When admin send request to user if user not registered then user register to self and
//directly join to the admin requested group by using URL parameter group Id and random number.
if (!empty($group_id) && !empty($random_no)) {
$this->Request($group_id, $random_no, $email);
//delete session values
CakeSession::delete('group_id');
CakeSession::delete('random_no');
}
$this->redirect('../Ideas/view_ideas');
} else {
CakeLog::write('info', '.....Invalid username or password...');
$this->Session->write('login_message', 'Invalid username or password');
$this->redirect('../');
}
}
示例8: authenticate
public function authenticate(CakeRequest $request, CakeResponse $response)
{
// Server Side Flow
$this->access_token = $this->_retrive_access_token($request);
if ($this->access_token) {
$user = $this->_retrive_userdata();
$user->access_token = $this->access_token;
$userModel = $this->settings['userModel'];
list($plugin, $model) = pluginSplit($userModel);
$fields = $this->settings['fields'];
$conditions = array($model . '.' . $fields['username'] => $user->id);
if (!empty($this->settings['scope'])) {
$conditions = array_merge($conditions, $this->settings['scope']);
}
$result = ClassRegistry::init($userModel)->find('first', array('conditions' => $conditions, 'recursive' => 0));
if (empty($result) || empty($result[$model])) {
$session_name = $this->settings['session'];
CakeSession::write($session_name, $user);
return false;
}
unset($result[$model][$fields['password']]);
$user->id = $result[$model]['_id'];
$session_name = $this->settings['session'];
CakeSession::write($session_name, $user);
return $result[$model];
}
return false;
}
示例9: login
public function login()
{
if (isset($this->Controller->request->query['code'])) {
$code = $this->Controller->request->query['code'];
}
if (isset($this->Controller->request->query['state'])) {
$state_request = $this->Controller->request->query['state'];
}
if (empty($code)) {
CakeSession::write('state', md5(uniqid(rand(), TRUE)));
$state_session = CakeSession::read('state');
// CSRF protection
$dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" . $this->app_id . "&redirect_uri=" . urlencode($this->my_url) . "&state=" . $state_session . "&scope=email";
$this->__redirectFunc($dialog_url);
}
if (CakeSession::read('state') && CakeSession::read('state') === $state_request) {
$token_url = "https://graph.facebook.com/oauth/access_token?client_id=" . $this->app_id . "&redirect_uri=" . urlencode($this->my_url) . "&client_secret=" . $this->app_secret . "&code=" . $code;
$response = file_get_contents($token_url);
parse_str($response, $params);
CakeSession::write('access_token', $params['access_token']);
$graph_url = "https://graph.facebook.com/me?access_token=" . CakeSession::read('access_token');
$user = json_decode(file_get_contents($graph_url));
return $user;
} else {
echo "The state does not match. You may be a victim of CSRF.";
}
}
示例10: signin
/**
* Signin URL
*
* @param string Anchor text
* @param string redirect url
* @return string HTML tag
*/
public function signin($text = 'Login', $redirect = null, $scope = null)
{
$api = Configure::read('SocialSignIn.API.Twitter');
$url = Router::url(array('plugin' => 'social_sign_in', 'controller' => 'oauth', 'action' => 'signin'));
CakeSession::write($this->session . '.callback', $redirect, true);
$output = '<a href="' . $url . '">' . $text . "</a>\n";
return $output;
}
示例11: testListLanguages
public function testListLanguages()
{
CakeSession::delete('Config.language');
$result = $this->MultiLanguage->listLanguages();
$this->assertRegExp('/<span class="hhh">\\s*English\\s*<\\/span>/i', $result);
CakeSession::write('Config.language', 'fra');
$result = $this->MultiLanguage->listLanguages();
$this->assertRegExp('/<span class="hhh">\\s*Français\\s*<\\/span>/i', $result);
}
示例12: afterSave
public function afterSave($created, $options = array())
{
parent::afterSave($created, $options);
if (AuthComponent::user()) {
App::uses('CakeSession', 'Model/Datasource');
CakeSession::write('Auth', $this->findById(AuthComponent::user('id')));
}
return true;
}
示例13: testAdminReset
/**
* QloginControllerTest::testAdminIndex()
*
* @return void
*/
public function testAdminReset()
{
$user = array('id' => 1, 'role_id' => 1);
CakeSession::write('Auth.User', $user);
$url = Router::url(array('admin' => true, 'plugin' => 'tools', 'controller' => 'tiny_urls', 'action' => 'reset'));
$result = $this->testAction($url, array('return' => 'contents'));
$this->assertNull($result);
$this->assertTextContains('admin/tools/tiny_urls', $this->headers['Location']);
}
示例14: testAdminMenus
/**
* testAdminMenus
*/
public function testAdminMenus()
{
CakeSession::write('Auth.User', array('id' => 1, 'role_id' => 1));
CroogoNav::add('contents', array('title' => 'Contents', 'url' => '#'));
$items = CroogoNav::items();
$expected = '<ul class="nav nav-stacked"><li><a href="#" class="menu-contents sidebar-item"><i class="icon-white icon-large"></i> <span>Contents</span></a></li></ul>';
$result = $this->Croogo->adminMenus(CroogoNav::items());
$this->assertEquals($expected, $result);
}
示例15: setCartConfiguration
public function setCartConfiguration(Model $Model, $id, $configuration)
{
$products = CakeSession::read('WebshopShoppingCart.products');
if ($products === null) {
$products = array();
}
$products[$id]['configuration'] = $configuration;
CakeSession::write('WebshopShoppingCart.products', $products);
}