Gayner Posted September 20, 2009 Share Posted September 20, 2009 When a user on my forum clicks on a link and it lets them view that page, I want them to beable to use that page for only 20second's then it refreshes them to a different page, and run a simple php mysql? Possible if so how? Thanks! sir Link to comment https://forums.phpfreaks.com/topic/174875-i-want-to-beable-to-use-a-session-expires-in-20-seconds-possible/ Share on other sites More sharing options...
Daniel0 Posted September 20, 2009 Share Posted September 20, 2009 session_set_cookie_params Link to comment https://forums.phpfreaks.com/topic/174875-i-want-to-beable-to-use-a-session-expires-in-20-seconds-possible/#findComment-921610 Share on other sites More sharing options...
ozestretch Posted September 20, 2009 Share Posted September 20, 2009 <html> <head> <meta http-equiv="refresh" content="20;url=http://www.takemehere.com/tomypage.php"> </head> etc... you may want to add php before outputting to see if they can be there to begin with etc.. Link to comment https://forums.phpfreaks.com/topic/174875-i-want-to-beable-to-use-a-session-expires-in-20-seconds-possible/#findComment-921612 Share on other sites More sharing options...
ozestretch Posted September 20, 2009 Share Posted September 20, 2009 session_set_cookie_params If that is used when loading the page/script, still needs to redirect after said time. Can he use your suggestion before outputting the html with a meta refresh?? Link to comment https://forums.phpfreaks.com/topic/174875-i-want-to-beable-to-use-a-session-expires-in-20-seconds-possible/#findComment-921614 Share on other sites More sharing options...
Gayner Posted September 20, 2009 Author Share Posted September 20, 2009 session_set_cookie_params Hey thanks for that link, but I cant find any examples on that. "Descrição void session_set_cookie_params ( int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly ]]]] ) Define parâmetros dos cookies como no arquivo php.ini file. O efeito desta função é apenas pela duração do script. Então, então você precisa chamar session_set_cookie_params() para cada requisição e antes que session_start() seja chamada. Nota: O parâmetro secure foi adicionado no PHP 4.0.4, enquanto o parâmetro httponly foi adicionado no PHP 5.2.0. " IS what PHP.net says and I dont understand? Thanks for ur time, but sir is it ok if I ask u to tidy up just a small 20second script that refreshes users stored session? Thanks daniel or anyone appreciated. Link to comment https://forums.phpfreaks.com/topic/174875-i-want-to-beable-to-use-a-session-expires-in-20-seconds-possible/#findComment-921619 Share on other sites More sharing options...
ozestretch Posted September 20, 2009 Share Posted September 20, 2009 <?php private function startSession($time = 3600, $ses = 'MYSES') { session_set_cookie_params($time); session_name($ses); session_start(); // Reset the expiration time upon page load if (isset($_COOKIE[$ses])) setcookie($ses, $_COOKIE[$ses], time() + $time, "/"); } ?> Source: PHP: session_set_cookie_params - Manual (20 September 2009) Link to comment https://forums.phpfreaks.com/topic/174875-i-want-to-beable-to-use-a-session-expires-in-20-seconds-possible/#findComment-921631 Share on other sites More sharing options...
Gayner Posted September 20, 2009 Author Share Posted September 20, 2009 <?php private function startSession($time = 3600, $ses = 'MYSES') { session_set_cookie_params($time); session_name($ses); session_start(); // Reset the expiration time upon page load if (isset($_COOKIE[$ses])) setcookie($ses, $_COOKIE[$ses], time() + $time, "/"); } ?> Source: PHP: session_set_cookie_params - Manual (20 September 2009) i get Parse error: syntax error, unexpected T_PRIVATE ? Link to comment https://forums.phpfreaks.com/topic/174875-i-want-to-beable-to-use-a-session-expires-in-20-seconds-possible/#findComment-921637 Share on other sites More sharing options...
ozestretch Posted September 20, 2009 Share Posted September 20, 2009 that was direct copy from php.net $time = 3600 // actually means 1hour (in seconds), so set to suit Also are you running php5 or 4? private I believe is a php5 thing that is used in a class... getting over my head I was simply pointing to a course of action you can try. If was I, I would try editing like; <?php function startSession($time = 3600, $ses = 'MYSES') { session_set_cookie_params($time); session_name($ses); session_start(); // Reset the expiration time upon page load if (isset($_COOKIE[$ses])) setcookie($ses, $_COOKIE[$ses], time() + $time, "/"); } $this=startSession('20','MYSESSIONAME'); ?> Link to comment https://forums.phpfreaks.com/topic/174875-i-want-to-beable-to-use-a-session-expires-in-20-seconds-possible/#findComment-921645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.