Php session_cache_limiter session_cache_expire and other functions

Source: Internet
Author: User

Session_cache_limiter () returns the name of the current cache restriction. if cache_limiter is specified, the name of the current cache restriction is changed to a new value. the cache limit controls the Cache Control for sending HTTP hair to the client. the header content of these page content rules can be cached. if the cache is set to "no cache", no client cache is allowed. however, public variables can be cached. 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 restriction. If cache_limiter is specified, the name of the current cache restriction is changed to a new value.

The cache limit controls the Cache Control for sending http hair to the client. the header content of these page content rules can be cached. if the cache is set to "no cache", no client cache is allowed. however, public variables can be cached. 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 beginning of the request. In this way, you need to call session_cache_limiter () for every request (before session_start ).

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 the session */
Session_start ();
/* Output result content */
Echo "the current session cache restriction is set to: $ cache_limiter <br/> ";
Echo "current session expiration time: $ cache_expire minutes ";
/*
Output result:
The cache limiter is now set to private
The cached session pages expire after 30 minutes


*/

// Instance 2

/* Set caceh to 'private '*/
Session_cache_limiter ('private ');
/* Return caceh limiters */
$ Cache_limiter = session_cache_limiter ();
Echo "the current session cache restriction is set to: $ cache_limiter <br/> ";


// Instance 3

$ Filename = "test. mpeg ";
$ Filepath = "test. mpeg ";
Session_start ();
/* Initialize the 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

);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.