本文整理汇总了PHP中Sessions::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Sessions::save方法的具体用法?PHP Sessions::save怎么用?PHP Sessions::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sessions
的用法示例。
在下文中一共展示了Sessions::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
public static function write($session_id, $data)
{
// encryption
$crypt = new Crypt();
$data = $crypt->encrypt($data);
$sessions = new Sessions();
$sessions->session_id = $session_id;
$sessions->data = $data;
$s = $sessions->where("session_id = ?", $session_id)->find();
if (is_null($s)) {
return $sessions->save();
}
$sessions->id = $s->id;
return $sessions->update();
}
示例2: getSessionId
public function getSessionId($low = false)
{
$real_id = $low ? $this->id . '_low' : $this->id;
$user_ip = Yii::app()->user->isGuest ? 'none' : Yii::app()->user->user_ip;
$session = Sessions::model()->findByAttributes(array('ip' => $user_ip, 'real_id' => $real_id), array('select' => 'session_id'));
if (!$session) {
$session = new Sessions();
$session->ip = $user_ip;
$session->real_id = $real_id;
$session->user_id = Yii::app()->user->isGuest ? 0 : Yii::app()->user->getId();
$session_key = Yii::app()->user->isGuest ? md5(time() . 'none' . uniqid()) : Yii::app()->user->session_key;
$session->session_id = md5($real_id . $session_key);
$session->save();
}
return $session->session_id;
}
示例3: get_session_key
/**
* RPC routine to create a session key.
*
* @access public
* @param string $username
* @param string $password
* @return string
*/
public function get_session_key($username, $password)
{
if ($this->_doLogin($username, $password)) {
$this->_jumpStartSession($username);
$sSessionKey = randomChars(32);
$session = new Sessions();
$session->id = $sSessionKey;
$session->expire = time() + Yii::app()->getConfig('iSessionExpirationTime');
$session->data = $username;
$session->save();
return $sSessionKey;
} else {
return array('status' => 'Invalid user name or password');
}
}
示例4: updateSessionDocument
/**
* Update session collection
*/
public function updateSessionDocument($csrfToken = null)
{
// get config
$this->initialize();
$session = null;
// get session document
if (!empty($csrfToken)) {
$session = Sessions::findFirst(array("conditions" => array("csrfToken" => $csrfToken)));
}
if (!empty($session)) {
// extend session
$session->expireDate = new MongoDate(strtotime("+6hour"));
$session->modifiedDate = new MongoDate();
if ($session->save() == false) {
foreach ($session->getMessages() as $message) {
$this->logger->log(sprintf('NAMESPACE=ControllerBase MESSAGE=%s', $message), \Phalcon\Logger::ERROR);
}
return false;
} else {
// session record updated successfully
return $session->csrfToken;
}
} else {
// create session
$session = new Sessions();
$session->csrfToken = $this->security->getTokenKey() . $this->security->getToken();
$session->expireDate = new MongoDate(strtotime("+6hour"));
$session->createdDate = new MongoDate();
$session->modifiedDate = new MongoDate();
if ($session->save() == false) {
foreach ($session->getMessages() as $message) {
$this->logger->log(sprintf('NAMESPACE=ControllerBase MESSAGE=%s', $message), \Phalcon\Logger::ERROR);
}
return false;
} else {
return $session->csrfToken;
}
}
}
示例5: array
// we posted . characters, but something converts them to _ (HTTP 1.1 standard)
$r = array();
foreach ($_REQUEST as $i => $v) {
$r[join('.', explode('_', $i))] = $v;
//convert _ back to .
}
$Sessions = array();
for ($i0 = 0; isset($r['0.' . $i0]); $i0++) {
$Sessions[$i0] = array('id' => @$r['0.' . $i0 . '.0'], 'nr' => @$r['0.' . $i0 . '.0'], 'panel' => @$r['0.' . $i0 . '.1'], 'court' => @$r['0.' . $i0 . '.2'], 'city' => @$r['0.' . $i0 . '.3'], 'clerk' => @$r['0.' . $i0 . '.5'], 'scheduled' => @$r['0.' . $i0 . '.6'], 'date of occurence' => @$r['0.' . $i0 . '.7']);
$Sessions[$i0]['judge'] = array();
for ($i1 = 0; isset($r['0.' . $i0 . '.4.' . $i1]); $i1++) {
$Sessions[$i0]['judge'][$i1] = @$r['0.' . $i0 . '.4.' . $i1 . ''];
}
}
$Sessions = new Sessions($Sessions);
if ($Sessions->save() !== false) {
die('ok:' . $_SERVER['PHP_SELF']);
} else {
die('');
}
exit;
// do not show the interface
}
$buttons = "";
if (isset($_REQUEST['edit'])) {
$edit = true;
} else {
$edit = false;
}
$Sessions = new Sessions();
writeHead("<TITLE>Sessions - VIRO - ADL Prototype</TITLE>" . ($edit ? '<SCRIPT type="text/javascript" src="edit.js"></SCRIPT>' : '<SCRIPT type="text/javascript" src="navigate.js"></SCRIPT>') . "\n");