Forum Moderators: coopster

Message Too Old, No Replies

session cache expire() empty cache after logging

         

Dlocks

7:45 pm on May 3, 2010 (gmt 0)

10+ Year Member



I would like to use the following code for visitors that are not logged in:

session_name( "session_id" );
session_cache_limiter ('private, must-revalidate');
$cache_limiter = session_cache_limiter();
session_cache_expire(15); // in minutes
session_start();


When I visitor visits a page within 15 minutes for the second time the page will be loaded from the browser cache.

Note: I only use the above code when a visitor is not logged in.

The above is working fine, but I have a problem with visitors after they login.

After login pages should not be loaded from the browser cache. I have tried using "session_destroy();" (see: www.php.net/manual/en/function.session-destroy.php and scroll down to user "iam4webwork") but that did not I work. Pages are still loaded from the browser cache.

What code should I use directly after some logs in to prevent page from caching?

Matthew1980

7:24 am on May 5, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there Dlocks,

Well, I have never used your method of "session for 15 minutes" before, but the first thing that strikes me is, are you using another session id for when the user logs in so that there are two distinct sessions going; one for non-user; one for registered user, or am I missing the point?

Also when setting sessions, would it not be easier to do:-

<?php
error_reporting(E_ALL);//turn on
session_start();//Start the session

$_SESSION['your_session'] = $Username;//or however you prefer

Only reason I ask/show is because you are using session_start(); after your assigning the name, when doing things like this, turn your error_reporting(E_ALL); on and from that, you will always be told of anything going off track..

Cheers,
MRb