本文整理汇总了PHP中set_session函数的典型用法代码示例。如果您正苦于以下问题:PHP set_session函数的具体用法?PHP set_session怎么用?PHP set_session使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_session函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make_mp3
function make_mp3()
{
global $config;
$number = get_session("ss_captcha_key");
if ($number == "") {
return;
}
if ($number == get_session("ss_captcha_save")) {
return;
}
$mp3s = array();
for ($i = 0; $i < strlen($number); $i++) {
$file = G5_CAPTCHA_PATH . '/mp3/' . $config['cf_captcha_mp3'] . '/' . $number[$i] . '.mp3';
$mp3s[] = $file;
}
$ip = sprintf("%u", ip2long($_SERVER['REMOTE_ADDR']));
$mp3_file = 'data/cache/kcaptcha-' . $ip . '_' . G5_SERVER_TIME . '.mp3';
$contents = '';
foreach ($mp3s as $mp3) {
$contents .= file_get_contents($mp3);
}
file_put_contents(G5_PATH . '/' . $mp3_file, $contents);
// 지난 캡챠 파일 삭제
if (rand(0, 99) == 0) {
foreach (glob(G5_PATH . '/data/cache/kcaptcha-*.mp3') as $file) {
if (filemtime($file) + 86400 < G5_SERVER_TIME) {
@unlink($file);
}
}
}
set_session("ss_captcha_save", $number);
return G5_URL . '/' . $mp3_file;
}
示例2: default_login
function default_login($un, $pp)
{
if ($un == "admin" && $pp == "admin123") {
set_session($un, $pp);
header("Location: main.php");
}
}
示例3: setSession
private function setSession($id)
{
sec_session();
set_session($id);
header('Location: ../../pocetna/');
die;
}
示例4: login
public function login()
{
global $PAGES;
// get log in information
$email = $this->session['login-email'];
$password = $this->session['login-password'];
$curr_user = null;
foreach ($this->all_users as $id => $user) {
if ($user->email === $email) {
$curr_user = $user;
break;
}
}
clear_session();
if ($curr_user !== null && password_verify($password, $curr_user->pass_salt_hash)) {
// password correct
set_session('user_id', $curr_user->id);
set_session('user_session_token', hash("sha512", mt_rand(0, mt_getrandmax())));
set_session('status', 'just_logged_in');
$this->curr_user = $curr_user;
} else {
$this->status = 'wrong_login';
}
$this->view();
}
示例5: save2session
function save2session($key, $value)
{
if (is_null($key) || is_null($value) || !is_string($key)) {
return false;
}
//将键值对放入session中
set_session($key, $value);
return true;
}
示例6: antiRePost
function antiRePost($sendStr)
{
global $RefreshType;
global $anit_refresh;
if ($sendStr == get_session('PostSendStr')) {
if (isset($RefreshType) == 'ajax') {
action_return(2, 'error:' . $anit_refresh, "-1");
} else {
action_return(1, $anit_refresh, "-1");
}
}
set_session('PostSendStr', $sendStr);
}
示例7: connect_error
function connect_error()
{
global $connection, $token, $error, $drivers;
$databases = array();
if (DB != "") {
page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), true);
} else {
if ($_POST["db"] && !$error) {
queries_redirect(substr(ME, 0, -1), lang('Databases have been dropped.'), drop_databases($_POST["db"]));
}
page_header(lang('Select database'), $error, false);
echo "<p><a href='" . h(ME) . "database='>" . lang('Create new database') . "</a>\n";
foreach (array('privileges' => lang('Privileges'), 'processlist' => lang('Process list'), 'variables' => lang('Variables'), 'status' => lang('Status')) as $key => $val) {
if (support($key)) {
echo "<a href='" . h(ME) . "{$key}='>{$val}</a>\n";
}
}
echo "<p>" . lang('%s version: %s through PHP extension %s', $drivers[DRIVER], "<b>{$connection->server_info}</b>", "<b>{$connection->extension}</b>") . "\n";
echo "<p>" . lang('Logged as: %s', "<b>" . h(logged_user()) . "</b>") . "\n";
if ($_GET["refresh"]) {
set_session("dbs", null);
}
$databases = get_databases();
if ($databases) {
$scheme = support("scheme");
$collations = collations();
echo "<form action='' method='post'>\n";
echo "<table cellspacing='0' class='checkable' onclick='tableClick(event);'>\n";
echo "<thead><tr><td> <th>" . lang('Database') . "<td>" . lang('Collation') . "<td>" . lang('Tables') . "</thead>\n";
foreach ($databases as $db) {
$root = h(ME) . "db=" . urlencode($db);
echo "<tr" . odd() . "><td>" . checkbox("db[]", $db, in_array($db, (array) $_POST["db"]));
echo "<th><a href='{$root}'>" . h($db) . "</a>";
echo "<td><a href='{$root}" . ($scheme ? "&ns=" : "") . "&database=' title='" . lang('Alter database') . "'>" . nbsp(db_collation($db, $collations)) . "</a>";
echo "<td align='right'><a href='{$root}&schema=' id='tables-" . h($db) . "' title='" . lang('Database schema') . "'>?</a>";
echo "\n";
}
echo "</table>\n";
echo "<script type='text/javascript'>tableCheck();</script>\n";
echo "<p><input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm("formChecked(this, /db/)", 1) . ">\n";
// 1 - eventStop
echo "<input type='hidden' name='token' value='{$token}'>\n";
echo "<a href='" . h(ME) . "refresh=1' onclick='eventStop(event);'>" . lang('Refresh') . "</a>\n";
echo "</form>\n";
}
}
page_footer("db");
if ($databases) {
echo "<script type='text/javascript'>ajaxSetHtml('" . js_adminer_escape(ME) . "script=connect');</script>\n";
}
}
示例8: get_user
function get_user()
{
$cookie_user = ci_get_cookie('user');
if ($cookie_user) {
$this->user = json_decode($cookie_user, true);
set_session('user', $this->user);
} else {
$this->user = get_session('user');
}
if ($this->user) {
$this->uid = $this->user['uid'];
$this->load->vars('user', $this->user);
}
}
示例9: login
function login()
{
$this->model->username = $_POST['username'];
$this->model->userpwd = $_POST['userpwd'];
$this->model->login_user();
if ($this->model->rows > 0) {
/*
* 登录成功,注册变量
*/
set_session('login', 'yes');
set_session('userID', $this->model->result['id']);
set_session('nickname', $this->model->result['nickname']);
}
header("Location:/admin");
}
示例10: login
public function login()
{
if (IS_POST) {
$user_name = I('post.user_name', '', 'htmlspecialchars');
$pwd = I('post.password', '');
if (empty($user_name) || empty($pwd)) {
$this->error('Incorrect account address or password. Please try again.');
}
$info = D('Users')->UserLogin($user_name, $pwd);
if ($info) {
set_cookies($info, $_POST['remember']);
set_session($info);
$this->success('Login successful.', U('index/index'));
}
$this->error('Incorrect account address or password. Please try again.');
}
}
示例11: set_new_company
function set_new_company($id)
{
set_session('company_id', $id);
set_session('company_name', max_size(get_table_value('Companies', 'name', $id), 40));
// clean up previous [Company] search sessions
unset_session('contact_search');
unset_session('domain_search');
unset_session('playlist_search');
unset_session('user_search');
unset_session('video_search');
// clean up previous [Company] page sessions
unset_session('contact_page');
unset_session('domain_page');
unset_session('playlist_page');
unset_session('user_page');
unset_session('video_page');
}
示例12: admin_login
function admin_login()
{
safe('admin_login');
global $smarty, $lang;
$username = substr(post('username'), 0, 30);
$password = substr(post('password'), 0, 30);
if ($username == '' || $password == '') {
unset_session('admin_username');
unset_session('admin_password');
$info_text = '对不起,用户名和密码不能为空';
$link_text = '返回重新登录';
} else {
$password = md5($password);
$obj = new admin();
$obj->set_field('adm_id,adm_last_login');
$obj->set_where("adm_username = '{$username}'");
$obj->set_where("adm_password = '{$password}'");
$one = $obj->get_one();
if (count($one) !== 0) {
set_session('session_id', session_id());
set_session('admin_username', $username);
set_session('admin_password', $password);
$adm_id = $one['adm_id'];
$adm_prev_login = $one['adm_last_login'];
$adm_last_login = time();
$obj->set_value('adm_prev_login', $adm_prev_login);
$obj->set_value('adm_last_login', $adm_last_login);
$obj->set_where('');
$obj->set_where("adm_id = {$adm_id}");
$obj->edit();
$info_text = '欢迎使用新秀文章管理系统后台';
$link_text = '进入后台';
} else {
unset_session('session_id');
unset_session('admin_username');
unset_session('admin_password');
$info_text = '对不起,用户名不存在或密码不正确';
$link_text = '返回重新登录';
}
}
$smarty->assign('info_text', $info_text);
$smarty->assign('link_text', $link_text);
$smarty->assign('link_href', $_SERVER['PHP_SELF']);
}
示例13: csrf_token
function csrf_token($name)
{
if (function_exists('hash_algos') && in_array('sha512', hash_algos())) {
$token = hash('sha512', mt_rand(0, mt_getrandmax()));
} else {
$token = '';
for ($i = 0; $i < 128; ++$i) {
$r = mt_rand(0, 35);
if ($r < 26) {
$c = chr(ord('a') + $r);
} else {
$c = chr(ord('0') + $r - 26);
}
$token .= $c;
}
}
set_session($name, $token);
return $token;
}
示例14: header
<?php
include_once "_common.php";
header("Content-Type: text/html; charset={$g4['charset']}");
require dirname(__FILE__) . '/kcaptcha_config.php';
include 'kcaptcha.php';
while (true) {
$keystring = '';
for ($i = 0; $i < $length; $i++) {
$keystring .= $allowed_symbols[mt_rand(0, strlen($allowed_symbols) - 1)];
}
if (!preg_match('/cp|cb|ck|c6|c9|rn|rm|mm|co|do|cl|db|qp|qb|dp|ww/', $keystring)) {
break;
}
}
set_session("captcha_count", 0);
set_session("captcha_keystring", $keystring);
$captcha = new KCAPTCHA();
$captcha->setKeyString(get_session("captcha_keystring"));
示例15: md5
<?php
include_once './_common.php';
if (USE_G5_THEME && defined('G5_THEME_PATH')) {
require_once G5_SHOP_PATH . '/yc/orderinquiryview.php';
return;
}
// 불법접속을 할 수 없도록 세션에 아무값이나 저장하여 hidden 으로 넘겨서 다음 페이지에서 비교함
$token = md5(uniqid(rand(), true));
set_session("ss_token", $token);
if (!$is_member) {
if (get_session('ss_orderview_uid') != $_GET['uid']) {
alert("직접 링크로는 주문서 조회가 불가합니다.\\n\\n주문조회 화면을 통하여 조회하시기 바랍니다.", G5_SHOP_URL);
}
}
$sql = "select * from {$g5['g5_shop_order_table']} where od_id = '{$od_id}' ";
if ($is_member && !$is_admin) {
$sql .= " and mb_id = '{$member['mb_id']}' ";
}
$od = sql_fetch($sql);
if (!$od['od_id'] || !$is_member && md5($od['od_id'] . $od['od_time'] . $od['od_ip']) != get_session('ss_orderview_uid')) {
alert("조회하실 주문서가 없습니다.", G5_SHOP_URL);
}
// 결제방법
$settle_case = $od['od_settle_case'];
// 주문상품
$item = array();
$arr_it_orderform = array();
$st_count1 = $st_count2 = 0;
$custom_cancel = false;
$sql = " select a.it_id,\n\t\t\t\ta.it_name,\n\t\t\t\ta.ct_send_cost,\n\t\t\t\ta.it_sc_type,\n\t\t\t\ta.pt_it,\n\t\t\t\tb.ca_id,\n\t\t\t\tb.ca_id2,\n\t\t\t\tb.ca_id3,\n\t\t\t\tb.pt_msg1,\n\t\t\t\tb.pt_msg2,\n\t\t\t\tb.pt_msg3\n\t\t from {$g5['g5_shop_cart_table']} a left join {$g5['g5_shop_item_table']} b on ( a.it_id = b.it_id )\n\t\t where a.od_id = '{$od_id}'\n\t\t group by a.it_id\n\t\t order by a.ct_id ";