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
Switch to threaded view of this topic Create a new topic Submit Reply
Session Cache [message #169384] Thu, 09 September 2010 03:24 Go to next message
GarryJones is currently offline  GarryJones
Messages: 21
Registered: September 2010
Karma: 0
Junior Member
If a user has missed something when they preview a form I want to
return them with the back button or the cancel button to the previous
page. Msie gives me the page expired error and firefox gives me a
button to reload. But then of course all the entered information is
gone...

Pages are
page1 (the form)
page 2 (preview page)
page 3 (confirmation page)

I googled around and found this

session_cache_limiter(private_no_expire);

With that at the top of each page it works but then I realised that it
might be a good thing to restict the length of time they can do this.

I googled on found something else so now I have put 3 lines of code at
the start of each page.

session_cache_limiter('public');
session_cache_expire (1);
session_start();

But the user can still go back and forth even after the one minute
deadline.

As usual I need help with the syntax, how to I flash up the page
expired error if a user clicks back say in 15-20 minutes?

Any help, greatly appreciated...


Garry Jones
Sweden
Re: Session Cache [message #169387 is a reply to message #169384] Thu, 09 September 2010 06:59 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 09/09/2010 5:24, GarryJones escribió/wrote:
> If a user has missed something when they preview a form I want to
> return them with the back button or the cancel button to the previous
> page. Msie gives me the page expired error and firefox gives me a
> button to reload. But then of course all the entered information is
> gone...
>
> Pages are
> page1 (the form)
> page 2 (preview page)
> page 3 (confirmation page)
>
> I googled around and found this
>
> session_cache_limiter(private_no_expire);
>
> With that at the top of each page it works but then I realised that it
> might be a good thing to restict the length of time they can do this.
>
> I googled on found something else so now I have put 3 lines of code at
> the start of each page.
>
> session_cache_limiter('public');
> session_cache_expire (1);
> session_start();
>
> But the user can still go back and forth even after the one minute
> deadline.
>
> As usual I need help with the syntax, how to I flash up the page
> expired error if a user clicks back say in 15-20 minutes?

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.


--
-- 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
--
Re: Session Cache [message #169394 is a reply to message #169387] Thu, 09 September 2010 11:57 Go to previous messageGo to next message
GarryJones is currently offline  GarryJones
Messages: 21
Registered: September 2010
Karma: 0
Junior Member
> 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()

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.

Garry Jones
Sweden
Re: Session Cache [message #169396 is a reply to message #169394] Thu, 09 September 2010 12:40 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
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
--
Re: Session Cache [message #169400 is a reply to message #169384] Thu, 09 September 2010 13:28 Go to previous messageGo to next message
rf is currently offline  rf
Messages: 19
Registered: September 2010
Karma: 0
Junior Member
GarryJones wrote:
> If a user has missed something when they preview a form I want to
> return them with the back button or the cancel button to the previous
> page. Msie gives me the page expired error and firefox gives me a
> button to reload. But then of course all the entered information is
> gone...

Using the browsers back button to "backspace" to a previous page in, as you
have, a multi page form is at best fragile. It's totally up to the browser
what happens when you press it's back button. It might refresh the page from
the server. It might display the page exactly as it was last displayed. It
might display it as it was last downloaded. None of this is under your
control.

Every multi page form I have ever come across never even suggests that I use
the browsers back button. They all have two quite clearly marked submit
buttons at the bottom usually labeled [next] and [previous]. Sometimes the
previous button is also annotated with prose that sort of says if you don't
like what you see (on this preview page) then press me to "go back" to the
actual entry page.

This is, however, not a "back" button. It is a "go forward" to the page you
were on last. It might be implemented via a redirect status code so the
browsers history is sort of continuous bit it does *not* use the browsers
history, as the browsers back button does. It is all done server side, where
you *do* have total control over what you present to your user.

Do not rely on the browsers back button.
Re: Session Cache [message #169402 is a reply to message #169384] Thu, 09 September 2010 14:41 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(GarryJones)

> If a user has missed something when they preview a form I want to
> return them with the back button or the cancel button to the previous
> page. Msie gives me the page expired error and firefox gives me a
> button to reload. But then of course all the entered information is
> gone...
>
> Pages are
> page1 (the form)
> page 2 (preview page)
> page 3 (confirmation page)

The usual way is to do 1) and 2) on the same page, i.e. submit the form
to itself. This makes it very easy to validate the input and simply show
the form again if something's wrong and missing, together with some
error message. Then the user can directly fix the mistakes and submit
again. If all is fine, the form script processes the data and shows the
confirmation page or redirects to one.

> I googled around and found this
>
> session_cache_limiter(private_no_expire);
>
> With that at the top of each page it works but then I realised that it
> might be a good thing to restict the length of time they can do this.
>
> I googled on found something else so now I have put 3 lines of code at
> the start of each page.
>
> session_cache_limiter('public');
> session_cache_expire (1);
> session_start();

This has _nothing_ to do with your form problem.

Micha
Re: Session Cache [message #169407 is a reply to message #169384] Fri, 10 September 2010 07:45 Go to previous messageGo to next message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma: 0
Senior Member
On 9/9/2010 5:24 AM, GarryJones wrote:
> If a user has missed something when they preview a form I want to
> return them with the back button or the cancel button to the previous
> page. Msie gives me the page expired error and firefox gives me a
> button to reload. But then of course all the entered information is
> gone...
>
> Pages are
> page1 (the form)
> page 2 (preview page)
> page 3 (confirmation page)
>
> I googled around and found this
>
> session_cache_limiter(private_no_expire);
>
> With that at the top of each page it works but then I realised that it
> might be a good thing to restict the length of time they can do this.
>
> I googled on found something else so now I have put 3 lines of code at
> the start of each page.
>
> session_cache_limiter('public');
> session_cache_expire (1);
> session_start();
>
> But the user can still go back and forth even after the one minute
> deadline.
>
> As usual I need help with the syntax, how to I flash up the page
> expired error if a user clicks back say in 15-20 minutes?
>
> Any help, greatly appreciated...
>
>
> Garry Jones
> Sweden

You might first want to read this before starting to approach this all
the wrong way:
http://en.wikipedia.org/wiki/Post/Redirect/Get

No need to mess around with session settings if you set up your logic
the right way. ;-)

Regards,
Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
Re: Session Cache [message #169442 is a reply to message #169407] Mon, 13 September 2010 10:49 Go to previous message
Piyush Gupta is currently offline  Piyush Gupta
Messages: 6
Registered: September 2010
Karma: 0
Junior Member
On Sep 10, 12:45 pm, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spamyourself.com> wrote:
> On 9/9/2010 5:24 AM, GarryJones wrote:
>
>
>
>
>
>> If a user has missed something when they preview a form I want to
>> return them with the back button or the cancel button to the previous
>> page. Msie gives me the page expired error and firefox gives me a
>> button to reload. But then of course all the entered information is
>> gone...
>
>> Pages are
>> page1 (the form)
>> page 2 (preview page)
>> page 3 (confirmation page)
>
>> I googled around and found this
>
>> session_cache_limiter(private_no_expire);
>
>> With that at the top of each page it works but then I realised that it
>> might be a good thing to restict the length of time they can do this.
>
>> I googled on found something else so now I have put 3 lines of code at
>> the start of each page.
>
>> session_cache_limiter('public');
>> session_cache_expire (1);
>> session_start();
>
>> But the user can still go back and forth even after the one minute
>> deadline.
>
>> As usual I need help with the syntax, how to I flash up the page
>> expired error if a user clicks back say in 15-20 minutes?
>
>> Any help, greatly appreciated...
>
>> Garry Jones
>> Sweden
>
> You might first want to read this before starting to approach this all
> the wrong way:http://en.wikipedia.org/wiki/Post/Redirect/Get
>
> No need to mess around with session settings if you set up your logic
> the right way. ;-)
>
> Regards,
> Erwin Moller
>
> --
> "There are two ways of constructing a software design: One way is to
> make it so simple that there are obviously no deficiencies, and the
> other way is to make it so complicated that there are no obvious
> deficiencies. The first method is far more difficult."
> -- C.A.R. Hoare

Hi ,

We at www.rntlabs.com [RNTLABS Software Solutions] have exciting
openings for the below

1/ PHP
2/ Designers
3/ Android
4/ iPhone
5/ QA
6/ ROR

Please apply at hr(at)rntlabs(dot)com ASAP .

Thanks

Piyush Gupta
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Not understanding HTML form
Next Topic: PHP variables eg. $_FILES
Goto Forum:
  

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

Current Time: Wed Nov 27 07:16:30 GMT 2024

Total time taken to generate the page: 0.02442 seconds