PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
gurjit
Forum Contributor
Posts: 314 Joined: Thu May 15, 2003 11:53 am
Location: UK
Post
by gurjit » Tue Nov 30, 2004 8:07 am
Hi all,
I need to make a session last until the browser is closed. The browser can be left open all day. So i thought the best way would be to refresh the page every 20 mins with a
Code: Select all
<meta http-equiv="refresh" content="0; url=home.php">
However i cant simply do this because i pass many variables on this page, which are either posted via a form or sent via a <href> link and i have many variables passed from popups back to this home.php page, so coding for each variable would be crazy.
The question is how can i display what variables are currently passed through the page whether they be <form> or <href> passed?
i tried
but this only displays the variables passed through a <href> link and not <form> variables. any other solutions.
thanks in advance
protokol
Forum Contributor
Posts: 353 Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:
Post
by protokol » Tue Nov 30, 2004 8:19 am
Try session_cache_limiter('private_no_expire');
[php_man]session_cache_limiter[/php_man]()
[php_man]session_cache_expire[/php_man]()
gurjit
Forum Contributor
Posts: 314 Joined: Thu May 15, 2003 11:53 am
Location: UK
Post
by gurjit » Tue Nov 30, 2004 8:27 am
I done this, so i assume that what will happen is that the session will last 8 hours?
If i open popups from home.php will these still keep the session open?
Code: Select all
session_cache_limiter('private');
$cache_limiter = session_cache_limiter();
session_cache_expire(28800);
session_start();
$cache_expire = session_cache_expire();
protokol
Forum Contributor
Posts: 353 Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:
Post
by protokol » Tue Nov 30, 2004 8:29 am
Yeah, I'm pretty sure this is the general idea. If you do popups, make sure you call those session functions on those pages as well.
gurjit
Forum Contributor
Posts: 314 Joined: Thu May 15, 2003 11:53 am
Location: UK
Post
by gurjit » Tue Nov 30, 2004 8:46 am
The session does not destroy when you re-login.
I have used
Code: Select all
<?php
session_start();
session_destroy();
session_unset();
?>
seems to cache now. how can i make sure the entire cache resets when you click on the logout link?
protokol
Forum Contributor
Posts: 353 Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:
Post
by protokol » Tue Nov 30, 2004 8:55 am
I haven't done this type of caching, but this _might_ work
session_cache_expire(0);
session_destroy();
gurjit
Forum Contributor
Posts: 314 Joined: Thu May 15, 2003 11:53 am
Location: UK
Post
by gurjit » Tue Nov 30, 2004 8:59 am
tried that no luck
protokol
Forum Contributor
Posts: 353 Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:
Post
by protokol » Tue Nov 30, 2004 9:05 am
OK, I realized caching it is not a good idea.
gurjit
Forum Contributor
Posts: 314 Joined: Thu May 15, 2003 11:53 am
Location: UK
Post
by gurjit » Tue Nov 30, 2004 9:06 am
any other ideas?
protokol
Forum Contributor
Posts: 353 Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:
Post
by protokol » Tue Nov 30, 2004 9:06 am
Actually, I'm wrong. Try doing:
Code: Select all
<?php
session_cache_limiter('nocache');
session_cache_expire(0);
session_start();
session_destroy();
?>
protokol
Forum Contributor
Posts: 353 Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:
Post
by protokol » Tue Nov 30, 2004 9:07 am
Keep using the caching stuff, but use this to set the default back to non-caching sessions and then expire and destroy the cache and session. In concept this seems like it would work, but again I'm not 100%.
gurjit
Forum Contributor
Posts: 314 Joined: Thu May 15, 2003 11:53 am
Location: UK
Post
by gurjit » Tue Nov 30, 2004 10:30 am
i tried everything but once you set
session_cache_limiter('nocache');
you cant give a limiter time.
Once you set it to
session_cache_limiter('private');
you cant take the cache away until you give your browser a control+F5 refresh if you login as another user.