bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

$f3->set(...,$ttl=0) Bypass Caching #1153

Closed lsafelix75 closed 4 years ago

lsafelix75 commented 5 years ago

Hi,

I am trying to save SESSION.id through: $f3->set(SESSION.id, 'user' ); #default $ttl=0

But, my SESSION.id never get saved. When i go through the base.php code, i see the following:

if ($ttl)
            // Persist the key-value pair
            Cache::instance()->set($this->hash($key).'.var',$val,$ttl);
        return $ref;

Is this as per degined? I thought $ttl=0 suppose to save the variable infinitely? Thanks

ikkez commented 5 years ago

You do not want to save a session value to cache, otherwise every user would get that value from cache, if existing. So forget about the $ttl on SESSION vars. If you want to extend the session time duration, see JAR.expire in F3 and session.gc_maxlifetime and session.cookie_lifetime in your php.ini

rmanleyreeve commented 5 years ago

The key should be a string, try: $f3->set('SESSION.id', 'user' );

set - Bind value to hive key mixed set ( string $key, mixed $val [, int $ttl = 0 ] )