AlexV
AlexV

Reputation: 23108

PHP session_cache_limiter(), session_cache_expire() and session_start()

I'm using session_cache_limiter() and session_cache_expire() at the top of my PHP 5.1.0 script, just before my session_start().

From PHP help:

[...] you need to call session_cache_limiter() for every request (and before session_start() is called).

But what if I don't call session_start()? Will session_cache_limiter() and session_cache_expire() work without a session_start() after them?

Thanks!

Upvotes: 1

Views: 7723

Answers (2)

Anthony Forloney
Anthony Forloney

Reputation: 91806

Example taken straight from "PHP: session_cache_limiter" off php.net

<?php
/* set the cache limiter to 'private' */
session_cache_limiter('private');
$cache_limiter = session_cache_limiter();
echo "The cache limiter is now set to $cache_limiter<br />";
?>

Quoted section below from original is false. See @eCaroth's comment below for corrected information.

Also, it depends on your definition of work, the functions will be called and will not throw an error if session_start() is not called, but thats pointless. The purpose of those functions are for sessions and in order to use sessions you need session_start() to be called.

Upvotes: 0

eCaroth
eCaroth

Reputation: 531

NO, ssession_cache_limiter and session_cache_expire merely modify the values php uses for session.cache_limiter and session.cache_expire (which are used when generating the session headers in session_start()) - the functions don't actually send out headers themselves, else you couldn't use them before session_start()

Upvotes: 2

Related Questions