zoukankan      html  css  js  c++  java
  • php session

    to use session,you can :

    session_start();  //must be on the top of file ,to check session exist
    if(isset($_SESSION["count"])){
    	$_SESSION["count"]+=1;
    	echo "count";
    }else{
    	$_SESSION["count"]=1;
    }
    echo "you viewd the page ".$_SESSION['count'] ."time";
    

    delete session have two ways
    one is

    session_destory(); //remove all session
    

    other is :

    unset($_SESSION["count"]);
    
    You don't need to call session_start() function to start a session when a user visits your site if you can set session.auto_start variable to 1 in php.ini file.
    

    if user ban to store cookie in his brower, you can use :
    you should close cookie in chrome brower.

    session_start();
    if(isset($_SESSION["count"])){
    	$_SESSION["count"]+=1;
    	echo "count";
    	if($_SESSION["count"]>10){
    		// unset($_SESSION["count"]);
    		session_destroy();
    	}
    }else{
    	$_SESSION["count"]=1;
    }
    echo "you viewd the page ".$_SESSION['count'] ."time";
    ?>
    <h2><?php echo "other way is".htmlspecialchars(SID);?></h2>
    

    it will bring session message to url,and send to server.

    additional:htmlspecialchars() is prevent website from xss.

  • 相关阅读:
    hdu 2490 队列优化dp
    poj 1836 LIS变形
    hdu 3410 单调栈
    51nod 1437
    51nod 1215 单调栈/迭代
    51nod 1102 单调栈
    51nod 1272 思维/线段树
    51nod 1279 单调栈
    SpringMVC收藏
    今天接触枚举类型,感觉是C里面应该才有的东西
  • 原文地址:https://www.cnblogs.com/cyany/p/10012152.html
Copyright © 2011-2022 走看看