Search code examples
cakephphttp-redirectwait

Cakephp redirect after x seconds?


I am looking for a simple redirect for cakephp 2.1 with a wait time.

I'd like the view page to redirect after -lets say 5 seconds- to an external url.

Any idea how I could implement this?

Thanks in advance


Solution

  • The easiest solutions either involve jquery/javascrpt, meta or php headers in a view. I do not believe cake has a dedicate way to do this but an alternative could be a simple for loop and just do a simple +1 count to like 5000 or whatever value is needed to take 5 seconds and then do the normal cake redirect.

    simple view examples.

    php header

    header('Refresh: 5; URL=http://site.com/controller/action');
    

    meta

    <meta http-equiv="refresh" content="5;url=http://site.com/controller/action"/>