FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Session Cache
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Session Cache [message #169396 is a reply to message #169394] Thu, 09 September 2010 12:40 Go to previous messageGo to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma:
Senior Member
El 09/09/2010 13:57, GarryJones escribió/wrote:
>> How do you want to recover previous form values? Saving them into a
>> session variable or leveraging the browser cache? You are mixing
>> directives for both purposes.
>
> Out of my depth as usual....
>
> What I want...
>
> The user fills in the form input textboxes, clicks textboxes and
> submits form for preview.
> The user sees he has misspelt something or forgotten to tick a box.
>
> He clicks back on the browser. If he does this within say 5 minutes
> then he will return to the form in its previous state, all text and
> boxes will still be entered and status held for checkboxes. (I have
> got this working). The user can also click cancel on the form instead
> of ok, For that I use<input type="button" value="Cancel"
> onClick="history.back()">
>
> The way I got this working was to put
> session_cache_limiter(private_no_expire); before the session_start()

Sorry if I didn't explain myself correctly. I think it's pretty clear
*what* you want to accomplish. But you don't even mention *how* you want
to do it.

Unless I misread your messages, you are not asking for generic ideas
about how it can be done in PHP. You mention some random PHP functions
you are using, you explain that "it didn't work" and you ask some
extremely specific questions that are difficult to put in context.


> If he has waited more than 5 minutes then "page has expired" will be
> displayed in msie. (Resend or something in firefox). In both msie&
> firefox the keyed in data is gone and he will have to start again. I
> don't care about macintosh, google crome, safari or iphone. If people
> use those products that can expect to have to key in the entire data
> again. I don't need to overwork this little problem. Msie v7+ and
> Firefox 2.6+ catches 99% of my users.
>
> For the timeout I tried
> session_cache_limiter('public');
> session_cache_expire (1);
> session_start();
>
> But that didn't work.
>
> So how do I "add" a timeout to
> session_cache_limiter(private_no_expire) ?
> no_expire makes me feel that a timeout can not be added. In that case
> what do I put in to get what I want, ability to use back and cancel
> for 5 minutes.

You cannot add a timeout to an HTTP header. The whole idea does not make
any sense... Given that you "quote" it, I presume it's not a literal
expression.

I'll start guessing:

You want to instruct the browser to keep an HTML document in cache for
certain amount of time (but not more).

In that case, you need to generate the following HTTP headers:

<?php

$minutes = 5;

header('Expires: ' . gmdate('D, d M Y H:i:s', time()+60*$minutes) . ' GMT');
header('Cache-Control: max-age=' . 60*$minutes . ', s-maxage=' .
60*$minutes . ', must-revalidate, proxy-revalidate');

session_cache_limiter(FALSE); // Disable cache headers by session_start()

if( session_id() ){
// session_start() has already generated a "Pragma: no-cache" header
if( function_exists('header_remove') ){
header_remove('Pragma');
}else{
header('Pragma:');
}
}

?>

I haven't tested with POST forms but it should possibly work.

Of course, it's up to the browser whether to obey or discard these
rules. If you want a stronger server-side control, you'd need to send a
new form each time (with previous values pre-filled).


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Not understanding HTML form
Next Topic: PHP variables eg. $_FILES
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 11:59:21 GMT 2024

Total time taken to generate the page: 0.05444 seconds