php session_cache_limiter session_cache_expire and other functions_PHP tutorial

WBOY
Release: 2016-07-13 10:54:16
Original
918 people have browsed it

session_cache_limiter() returns the name of the current cache limit. If cache_limiter is specified, the name of the current cache limit is changed to the new value. Cache limits control the cache control of HTTP headers sent to the client. The content of these headers that determine the content of the page can be cached. If the cache setting is set to no cache (nocache), no client caching will be allowed. However, public variables can allow caching . It can also be set to private, which is a little more restrictive than public.

string session_cache_limiter ([string cache_limiter])

session_cache_limiter() returns the name of the current cache limit. If cache_limiter is specified, the name of the current cache limit is changed to the new value.

Cache limits control the cache control of http headers sent to the client. The content of these headers that determine the rules of page content can be cached. If the cache setting is set to no cache (nocache), no client caching will be allowed. But public variables Caching can be allowed. It can also be set to private, which is a little more restrictive than public.

The cache display is reset to the default value of session_cache_limiter at the start of the request. This way, you need to call session_cache_limiter() for every request (before session_start() is called).

Set cache limit to 'private'
*/

session_cache_limiter('private');
$cache_limiter=session_cache_limiter();
/*Set the session expiration time to 30 seconds*/
session_cache_expire(30);
$cache_expire=session_cache_expire();
/*Initialize session*/
session_start();
/*Output result content*/
echo "The current session cache limit is set to: $cache_limiter
";
echo "The current session expiration time is: $cache_expire minutes";
/*
The output result is:
the cache limiter is now set to private
the cached session pages expire after 30 minutes


*/

//Example 2

/*Set the caceh limiter to 'private'*/
session_cache_limiter('private');
/*Return to caceh limiter*/
$cache_limiter=session_cache_limiter();
echo "The current session cache limit is set to: $cache_limiter
";


//Example 3

$filename="test.mpeg";
$filepath="test.mpeg";
session_start();
/*Initialize session*/
session_commit();
/*Output the requested file*/
header("content-type: audio/x-mpeg"); //or other types of files
header("content-disposition:attachment;filename=".$filename);
header("content-length:".$filesize);
header("content-transfer-encoding:binarynn");
header("pragma:no-cache");
header("expires:0");
$file_contents=file_get_contents($filepath);
print($file_contents

);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632344.htmlTechArticlesession_cache_limiter() returns the name of the current cache limit. If cache_limiter is specified, the name of the current cache limit is changed to New value. Cache limit controls the HTTP headers sent to the client...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!