当前位置: 首页>>代码示例>>PHP>>正文


PHP startSession函数代码示例

本文整理汇总了PHP中startSession函数的典型用法代码示例。如果您正苦于以下问题:PHP startSession函数的具体用法?PHP startSession怎么用?PHP startSession使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了startSession函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loggedInOrRedirect

function loggedInOrRedirect()
{
    startSession();
    if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {
        die(header('Location: login.php'));
    }
}
开发者ID:qqalexqq,项目名称:Projects_645,代码行数:7,代码来源:global_functions.php

示例2: checkFormToken

function checkFormToken($tokenName, $formTokenValue){
    startSession();
    if ($formTokenValue != $_SESSION[$tokenName]){
        exit('ERROR: invalid form token! Do not submit your form twice.');
    }
    unset($_SESSION[$tokenName]);
}
开发者ID:ngduc,项目名称:Thin-PHP-Framework,代码行数:7,代码来源:security_util.php

示例3: logOut

function logOut()
{
    startSession();
    $_SESSION['id'] = '';
    $_SESSION['username'] = '';
    session_destroy();
    header("Location: index.php");
}
开发者ID:andresiggesjo,项目名称:Ando,代码行数:8,代码来源:functions.php

示例4: saveSession

function saveSession($email, $usertype, $firstname, $lastname, $userid)
{
    startSession();
    $_SESSION['userid'] = $userid;
    $_SESSION['firstname'] = $firstname;
    $_SESSION['lastname'] = $lastname;
    $_SESSION['email'] = $email;
    $_SESSION['usertype'] = $usertype;
}
开发者ID:efdalustaoglu,项目名称:secure-coding,代码行数:9,代码来源:user.php

示例5: loginAction

function loginAction()
{
    $email = $_POST['email'];
    $pass = $_POST['password'];
    $remember = $_POST['rememberData'];
    $result = login($email);
    if ($result['message'] == 'OK') {
        $key = pack('H*', "bcb04b7e103a05afe34763051cef08bc55abe029fdebae5e1d417e2ffb2a00a3");
        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        # --- DECRYPTION ---
        $ciphertext_dec = base64_decode($result['password']);
        $iv_dec = substr($ciphertext_dec, 0, $iv_size);
        $ciphertext_dec = substr($ciphertext_dec, $iv_size);
        $plaintext_dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec);
        $count = 0;
        $length = strlen($plaintext_dec);
        for ($i = $length - 1; $i >= 0; $i--) {
            if (ord($plaintext_dec[$i]) === 0) {
                $count++;
            }
        }
        $plaintext_dec = substr($plaintext_dec, 0, $length - $count);
        if ($plaintext_dec === $pass) {
            $response = array('fName' => $result['fName'], 'lName' => $result['lName']);
            # Starting the sesion (At the server)
            startSession($result['fName'], $result['lName'], $result['email']);
            $inTwoMonths = 60 * 60 * 24 * 60 + time();
            # Setting the cookies
            if ($remember) {
                setcookie("cookieUsername", $result['email'], $inTwoMonths);
                setcookie("cookiePassword", $result['password'], $inTwoMonths);
            } else {
                //if (isset($_COOKIE['cookieUsername']) && isset(($_COOKIE['cookiePassword']))) {
                unset($_COOKIE['cookieUsername']);
                unset($_COOKIE['cookiePassword']);
                //}
            }
            echo json_encode($response);
        } else {
            die(json_encode(errors(206)));
        }
    } else {
        die(json_encode($result));
    }
}
开发者ID:jorgelp94,项目名称:twitterclone,代码行数:46,代码来源:applicationLayer.php

示例6: formulaireIdentification

function formulaireIdentification()
{
    startSession();
    if ($_SESSION["connu"] === true) {
        printSession();
    } else {
        if (!isset($_POST["submit_login"])) {
            print_login_form();
        } else {
            $resultat = login($_POST["mail"], $_POST["mdp"]);
            if ($resultat === true) {
                printSession();
                echo "Authentification r&eacute;ussie.</br>\n";
            } else {
                print_login_form();
                echo "Mauvais mail ou mot de passe.</br>";
            }
        }
    }
}
开发者ID:andy-metz,项目名称:tequila,代码行数:20,代码来源:login.php

示例7: bootswatchFeedback

    /**
     * shows a quick user message (flash/heads up) to provide user feedback
     *
     * Uses a Session to store the data until the data is displayed via bootswatchFeedback()
     *
     * Related feedback() function used to store message 
     *
     * <code>
     * echo bootswatchFeedback(); #will show then clear message stored via feedback()
     * </code>
     * 
     * @param none 
     * @return string html & potentially CSS to style feedback
     * @see feedback() 
     * @todo none
     */
    function bootswatchFeedback()
    {
        startSession();
        //startSession() does not return true in INTL APP!
        $myReturn = "";
        //init
        if (isset($_SESSION['feedback']) && $_SESSION['feedback'] != "") {
            #show message, clear flash
            if (isset($_SESSION['feedback-level'])) {
                $level = $_SESSION['feedback-level'];
            } else {
                $level = '';
            }
            switch ($level) {
                case 'warning':
                    $level = 'warning';
                    break;
                case 'info':
                case 'notice':
                    $level = 'info';
                    break;
                case 'success':
                    $level = 'success';
                    break;
                case 'error':
                case 'danger':
                    $level = 'danger';
                    break;
            }
            $myReturn .= '
			<div class="alert alert-dismissable alert-' . $level . '" style="margin-top:.5em;">
			<button class="close" data-dismiss="alert" type="button">&times;</button>
			' . $_SESSION['feedback'] . '</div>
			';
            $_SESSION['feedback'] = "";
            #cleared
            $_SESSION['feedback-level'] = "";
        }
        return $myReturn;
        //data passed back for printing
    }
开发者ID:newmanix,项目名称:sm15-itc260,代码行数:57,代码来源:common_helper.php

示例8: action

 public static function action()
 {
     // 注册AUTOLOAD方法
     spl_autoload_register(['self', 'autoload']);
     define('_DOMAIN_', empty($_SERVER["HTTP_HOST"]) ? 'api.grlend.com' : $_SERVER["HTTP_HOST"]);
     ini_set('date.timezone', 'Asia/Shanghai');
     // 设置时区
     ini_set("display_errors", "On");
     error_reporting(E_ALL);
     header("Content-type:text/html;charset=utf-8");
     header("PowerBy: Han-zi,Liang");
     header("F-Version: 1.0");
     //框架版本
     //载入防xss和sql注入文件
     require_once 'waf.php';
     //载入系统函数
     require_once 'function.php';
     startSession();
     //启动程序
     self::start();
 }
开发者ID:phpchen,项目名称:yiyuangou,代码行数:21,代码来源:Entrance.class.php

示例9: fillSession

function fillSession($array)
{
    startSession();
    $err = fullCheck($array);
    if ($err != "") {
        return $err;
    }
    if (!isset($array["connu"])) {
        sessionFillDefault();
        return "Pofil inconnu.</br>\n";
    }
    if ($array["connu"] === false) {
        sessionFillDefault();
        return;
    }
    foreach ($varNames as $name) {
        //echo '$_SESSION['.$name.'] = $array['.$name.'];</br>\n';
        $_SESSION[$name] = $array[$name];
    }
    $_SESSION["connu"] = $array["connu"];
    return "";
}
开发者ID:andy-metz,项目名称:tequila,代码行数:22,代码来源:session.php

示例10: validateUser

function validateUser($username, $password)
{
    $conn = connectToDataBase();
    $sql = "SELECT * FROM User WHERE userName = \"" . $username . "\" AND userPassword = \"" . $password . "\"";
    $result = mysqli_query($conn, $sql);
    $array = array();
    if (mysqli_num_rows($result) > 0) {
        $array["response"] = "accepted";
        $sql = "SELECT rolId, institutionId\n              FROM HasRole hr, WorksInInstitution wi\n              WHERE hr.userName = \"" . $username . "\" AND\n              hr.userName = wi.userName;";
        $result = mysqli_query($conn, $sql);
        if ($row = mysqli_fetch_assoc($result)) {
            $array["rolId"] = $row["rolId"];
            $array["institutionId"] = $row["institutionId"];
            $array["userName"] = $username;
            startSession($array);
        }
    } else {
        $array["response"] = "declined";
    }
    closeDb($conn);
    echo json_encode($array);
}
开发者ID:EduardoVaca,项目名称:KidsMatter,代码行数:22,代码来源:login.php

示例11: showFeedback

/**
 * shows a quick user message (flash/heads up) to provide user feedback
 *
 * Uses a Session to store the data until the data is displayed via showFeedback()
 *
 * Related feedback() function used to store message 
 *
 * <code>
 * echo showFeedback(); #will show then clear message stored via feedback()
 * </code>
 * 
 * changed from showFeedback() version 2.10
 *
 * @param none 
 * @return string html & potentially CSS to style feedback
 * @see feedback() 
 * @todo none
 */
function showFeedback()
{
    startSession();
    //startSession() does not return true in INTL APP!
    $myReturn = "";
    //init
    if (isset($_SESSION['feedback']) && $_SESSION['feedback'] != "") {
        #show message, clear flash
        if (defined('THEME_PHYSICAL') && file_exists(THEME_PHYSICAL . 'feedback.css')) {
            //check to see if feedback.css exists - if it does use that
            $myReturn .= '<link href="' . THEME_PATH . 'feedback.css" rel="stylesheet" type="text/css" />' . PHP_EOL;
        } else {
            //create css for feedback
            $myReturn .= '
				<style type="text/css">
				.feedback {  /* default style for div */
					border: 1px solid #000;
					margin:auto;
					width:100%;
					text-align:center;
					font-weight: bold;
				}
			
				.error {
				  color: #000;
				  background-color: #ee5f5b; /* error color */
				}
			
				.warning {
				  color: #000;
				  background-color: #f89406; /* warning color */
				}
			
				.notice {
				  color: #000;
				  background-color: #5bc0de; /* notice color */
				}
				
				.success {
				  color: #000;
				  background-color: #62c462; /* notice color */
				}
				</style>
				';
        }
        if (isset($_SESSION['feedback-level'])) {
            $level = $_SESSION['feedback-level'];
        } else {
            $level = 'warning';
        }
        $myReturn .= '<div class="feedback ' . $level . '">' . $_SESSION['feedback'] . '</div>';
        $_SESSION['feedback'] = "";
        #cleared
        $_SESSION['feedback-level'] = "";
        return $myReturn;
        //data passed back for printing
    }
}
开发者ID:briannakarle,项目名称:itc250-p3-newsaggregator,代码行数:76,代码来源:common_inc.php

示例12: securePage

function securePage()
{
    global $conf;
    // If the sessionID is not present start the session (reading the
    // users cookie and loading their settings from disk)
    if (ONA_SESSION_ID != "") {
        startSession();
    }
    // Make sure their session is still active
    if (!isset($_SESSION['ona']['auth']['user']['username'])) {
        //header("Location: {$https}{$baseURL}/login.php?expired=1");
        exit;
    }
    return 0;
}
开发者ID:edt82,项目名称:ona,代码行数:15,代码来源:functions_general.inc.php

示例13:

include 'includes/header.php';
?>
<h1><?php 
echo $pageID;
?>
</h1>
<?php 
//customer_view.php - shows details of a single customer
if ($Feedback == '') {
    //data exists, show it
    echo '<p>';
    echo 'FirstName: <b>' . $FirstName . '</b> ';
    echo 'LastName: <b>' . $LastName . '</b> ';
    echo 'Email: <b>' . $Email . '</b> ';
    echo '<img src="uploads/customer' . $id . '.jpg" />';
    if (startSession() && isset($_SESSION["AdminID"])) {
        # only admins can see 'peek a boo' link:
        echo '<p align="center"><a href="' . VIRTUAL_PATH . 'upload_form.php?' . $_SERVER['QUERY_STRING'] . '">UPLOAD IMAGE</a></p>';
        /*
        # if you wish to overwrite any of these options on the view page, 
        # you may uncomment this area, and provide different parameters:						
        echo '<div align="center"><a href="' . VIRTUAL_PATH . 'upload_form.php?' . $_SERVER['QUERY_STRING']; 
        echo '&imagePrefix=customer';
        echo '&uploadFolder=upload/';
        echo '&extension=.jpg';
        echo '&createThumb=TRUE';
        echo '&thumbWidth=50';
        echo '&thumbSuffix=_thumb';
        echo '&sizeBytes=100000';
        echo '">UPLOAD IMAGE</a></div>';
        */
开发者ID:tianagreisel,项目名称:itc240-retrodiner,代码行数:31,代码来源:customer_view.php

示例14: foreach

<?php

/**
 * Created by PhpStorm.
 * User: Zerzolar
 * Date: 12.3.2016 г.
 * Time: 23:09
 */
require_once 'dbClass.php';
require_once "Sessions.php";
$user = $_POST;
foreach ($user as $key => $val) {
    $user[$key] = trim($user[$key]);
    $user[$key] = mysqli_real_escape_string($db->link, $user[$key]);
}
$query = "SELECT * FROM `users` WHERE `users`.`username` = '" . $user['username'] . "'";
$result = $db->fetchArray($query);
if (count($result) > 0) {
    if ($result[0]['password'] == md5($user['password'])) {
        startSession($result[0]['id'], $result[0]['username'], $result[0]['email'], $result[0]['firstname'], $result[0]['lastname'], $result[0]['gender'], $result[0]['birthdate'], $result[0]['joindate'], $result[0]['profilePicId']);
        echo $result[0]['profilePicId'];
        exit;
    }
}
echo "error";
开发者ID:hristo1998,项目名称:Abnormal-Graphics,代码行数:25,代码来源:login.php

示例15: viewRegister

function viewRegister()
{
    $errors = array();
    if (!empty($_POST)) {
        //vorm esitati
        if (empty($_POST["name"])) {
            $errors[] = "Nimi puudub.";
        }
        //nimi olemas
        $u = validateInput($_POST["name"]);
        $p1 = '';
        $p2 = '';
        $userMatch = false;
        $sql = "SELECT username FROM rsaarmae_users";
        $result = mysqli_query($_SESSION['connection'], $sql);
        while ($row = mysqli_fetch_assoc($result)) {
            if ($row['username'] == $u) {
                $userMatch = true;
                $errors[] = "Sellise nimega kasutaja on juba registreeritud, proovige teist nime";
            }
        }
        if (empty($_POST["name"])) {
        }
        if (empty($_POST["password"])) {
            $errors[] = "Salasõna puudub.";
        } else {
            $p1 = validateInput($_POST["password"]);
        }
        if (empty($_POST["password_check"])) {
            $errors[] = "Salasõna kontroll puudub.";
        } else {
            $p2 = validateInput($_POST["password_check"]);
        }
        if ($p1 != $p2) {
            $errors[] = "Salasõnad ei ühti.";
        }
        if (!$userMatch && empty($errors)) {
            $salt = sha1($p1 . $u . $p1);
            //salasõna räsi tekitamine ja soolamine
            $query = "INSERT INTO rsaarmae_users (username, pass) VALUES ('{$u}', '{$salt}');";
            mysqli_query($_SESSION['connection'], $query);
            startSession();
            startSession();
            $_SESSION["teade"] = "Registreeritud kasutaja nimega '" . $u . "'.";
            header("Location: controller.php?mode=index");
            exit(0);
        }
    }
    require_once 'register.php';
}
开发者ID:saarmae,项目名称:VR1,代码行数:50,代码来源:functions.php


注:本文中的startSession函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。