CodeIgniter Forums
Redirect page after some delay - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Redirect page after some delay (/showthread.php?tid=28359)



Redirect page after some delay - El Forum - 03-09-2010

[eluser]Suhas nazir[/eluser]
Is there any way to redirect a page in code igniter after a particular period of time.like meta..


Redirect page after some delay - El Forum - 03-09-2010

[eluser]troy_mccormick[/eluser]
A read through the entire user guide may be in order for you, but here is the relevant section for you:

Quote:redirect()

Does a "header redirect" to the local URI specified. Just like other functions in this helper, this one is designed to redirect to a local URL within your site. You will not specify the full site URL, but rather simply the URI segments to the controller you want to direct to. The function will build the URL based on your config file values.

The optional second parameter allows you to choose between the "location" method (default) or the "refresh" method. Location is faster, but on Windows servers it can sometimes be a problem. The optional third parameter allows you to send a specific HTTP Response Code - this could be used for example to create 301 redirects for search engine purposes. The default Response Code is 302. The third parameter is only available with 'location' redirects, and not 'refresh'. Examples:

Code:
if ($logged_in == FALSE)
{
     redirect('/login/form/', 'refresh');
}



Redirect page after some delay - El Forum - 03-09-2010

[eluser]Suhas nazir[/eluser]
Sry i am actually looking to redirect a page after a particular period of time for example after a 5 second..is there any way.


Redirect page after some delay - El Forum - 03-09-2010

[eluser]troy_mccormick[/eluser]
Why not put the meta tag within your view then? I'm sure you could extend the URL Helper to let the refresh time to be configurable too. Just a thought.


Redirect page after some delay - El Forum - 03-09-2010

[eluser]Suhas nazir[/eluser]
meta tag is some what html oriented infact i am looking for a codeigniter code any way thanks fr ur replay...


Redirect page after some delay - El Forum - 03-09-2010

[eluser]nelson.wells[/eluser]
Look up the php function sleep(). Maybe in your controller you could sleep the script for 5 seconds (or however long) before you send the headers. I haven't tried it, but it is worth a shot.


Redirect page after some delay - El Forum - 03-09-2010

[eluser]dark_lord[/eluser]
What about trying to embed this one on your meta tags?

<meta http-equiv="refresh" content="600">

600 - is the amount of time to wait before it redirects.


Redirect page after some delay - El Forum - 05-19-2010

[eluser]Unknown[/eluser]
Late reply but I believe that this will do what you want:
Code:
$this->output->set_header('refresh:5;url=wherever.php');

further documentation can be found here:
http://ellislab.com/codeigniter/user-guide/libraries/output.html


Redirect page after some delay - El Forum - 08-09-2010

[eluser]Cesar Kohl[/eluser]
I inserted this:

Code:
$this->output->set_header('refresh:3; url='.$this->base);

Thank you for this tip, Alt_F4!


Redirect page after some delay - El Forum - 10-23-2010

[eluser]Unknown[/eluser]
use this code in your controller :

header("RefreshConfusedeconds;url="your path");

eg:
header("Refresh:10;url=".base_url()."index.php/welcome");