Welcome Guest, Not a member yet? Register   Sign In
redirect with a pause
#1

[eluser]Unknown[/eluser]
Hi everyone,

I have this function in one of my controllers:

Code:
public function notAuthorized(){
  $this->load->view('base/notAuthorized');
  redirect('base/index','refresh:5');
}

The redirect works and pauses but won't show the view for those 5 seconds... I would like to see the loaded view and then redirect. I've also tried reversing the order.

This is what the view contains (a stupid page at the mo):
Code:
<html>
<head></head>
<body>
<?php
echo "Not Authorized";
?>
</body>
</html>
#2

[eluser]CroNiX[/eluser]
Looking at the URL helper, it seems you can't as the duration is hardcoded with 0.

Code:
switch ($method)
{
case 'refresh':
  header('Refresh:0;url='.$uri);
  break;
default:
  header('Location: '.$uri, TRUE, $code);
  break;
}
You can always use $this->output->set_header() to manually do it, or extend the native url_helper to allow passing in a refresh duration.




Theme © iAndrew 2016 - Forum software by © MyBB