Home > php教程 > PHP开发 > How to call session data in ThinkPHP template

How to call session data in ThinkPHP template

高洛峰
Release: 2016-12-22 10:46:08
Original
1386 people have browsed it

There are many ways to call session data in the template of the ThinkPHP framework, which can be used flexibly according to the situation. The common ones are as follows:

1. Directly call {$Think.session} in the template to obtain the session;

2. Write php code directly in the tag to call $_SESSION data;

3. Write in the template, and then write php code directly in it to call $_SESSION;

4. In Action, assign the $_SESSION variable to the template through the assign() method;

5. In the custom function library, create a new function to return the $_SESSION variable, and then use the {$ variable command in the template file | Function name} to assign the $_SESSION returned by the function to a variable in the template

In addition to the above 5 methods, readers can also develop new calling methods according to their own preferences.

I hope this article will help you design PHP programs based on the ThinkPHP framework.

For more related articles on how to call session data in ThinkPHP templates, please pay attention to the PHP Chinese website!

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template