Home > Backend Development > PHP Tutorial > php smarty 如何获取session

php smarty 如何获取session

WBOY
Release: 2016-06-13 12:12:33
Original
1536 people have browsed it

php smarty 怎么获取session
php 我知道是  比如说在判断用户登录的时候 $_SESSION['nicheng']=$rs['user_nicheng'];
这样   然后再 页面上加上
session_start();
?>
   然后你就可以这样
能输出你想要的值。
smarty这样完全不行  tpl页面要通过来传递  关键是我怎么获取session来分配变量
------解决思路----------------------
{$smarty.session.id}  PHP方式:$_SESSION["id"]
------解决思路----------------------
{$smarty.session.nicheng}
------解决思路----------------------
简单来说如果你在登陆页面用php对session赋值例如这句$_SESSION['nicheng']=$rs['user_nicheng'];
然后在任何一个模板页面都可以用{$smarty.session.nicheng}(那个大括号是smarty默认分隔符)来获取$_SESSION['nicheng']值
在任何一个php页面都可以用$_SESSION['nicheng']来获取$_SESSION['nicheng']值(php页面获取前提是得有session_start())
在多说点模板页面其实还有几个常用的获取get传的值获取post传的值和获取cookie、session等
{$smarty.session.nicheng}获取session值
{$smarty.post.postname}获取post提交的表单里面值(postname表单里面name值)
{$smarty.get.getname}获取gett提交的表单里面值(getname表单里面name值)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template