473,729 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP redirect timeout

Hi All,

Can anyone suggest a reliable solution to php redirect?:

header("Locatio n: $redir_url");
if the above times out in $timeout seconds
header("Locatio n: $alt_redir_url" );

Many thanks,

Dave
Mar 28 '06 #1
5 19401
Dave wrote:
Hi All,

Can anyone suggest a reliable solution to php redirect?:

header("Locatio n: $redir_url");
if the above times out in $timeout seconds
header("Locatio n: $alt_redir_url" );

Many thanks,

Dave


Hi, Dave,

Sorry, you can't do it.

When you send the redirect, the request goes to the browser. The browser is now
responsible for fetching the new page. Your script is no longer "in the loop".

Maybe you could do it with javascript - I haven't tried. But that would have
its own problems (i.e. user has disabled javascript).

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Mar 28 '06 #2
Jerry Stuckle <js*******@attg lobal.net> wrote in
news:Zs******** ************@co mcast.com:
Dave wrote:
Hi All,

Can anyone suggest a reliable solution to php redirect?:

header("Locatio n: $redir_url");
if the above times out in $timeout seconds
header("Locatio n: $alt_redir_url" );

Many thanks,

Dave


Hi, Dave,

Sorry, you can't do it.

When you send the redirect, the request goes to the browser. The
browser is now responsible for fetching the new page. Your script is
no longer "in the loop".

Maybe you could do it with javascript - I haven't tried. But that
would have its own problems (i.e. user has disabled javascript).


Actually, what could be done is to check for a good response at new URL
with fsockopen() and if successful, do the redirect, otherwise go to the
alternate.

To the OP:
peruse the info here: http://us2.php.net/function.fsockopen

--
Karl Groves
http://karlcore.com
http://chevelle.karlcore.com

Accessibility Discussion List: http://smallerurl.com/?id=6p764du
Mar 28 '06 #3
Actually, what I ended up doing was to use curl to request a very small
graphic from the site.
Used curl timeout to control the redirect time and got just the header.

$timeout = 10;
$testurl = "www.example.co m/small.gif";

$ch = curl_init();
curl_setopt($ch , CURLOPT_HEADER, 1);
curl_setopt($ch , CURLOPT_NOBODY, 1);
curl_setopt($ch , CURLOPT_URL,$te sturl);
curl_setopt($ch , CURLOPT_RETURNT RANSFER,1);
curl_setopt($ch , CURLOPT_TIMEOUT , $timeout);
$source = curl_exec($ch);
curl_close($ch) ;

if ($source!="") // optionally I could have tested for HTTP status, 404,
301, etc.
$url = "http://www.example.com/";
else
$url = "http://www.example.net/";
header("Locatio n: $url");

Thanks to all who responded,

Dave
"Karl Groves" <ka**@NOSPAMkar lcore.com> wrote in message
news:Xn******** *************** ******@216.196. 97.136...
Jerry Stuckle <js*******@attg lobal.net> wrote in
news:Zs******** ************@co mcast.com:
Dave wrote:
Hi All,

Can anyone suggest a reliable solution to php redirect?:

header("Locatio n: $redir_url");
if the above times out in $timeout seconds
header("Locatio n: $alt_redir_url" );

Many thanks,

Dave


Hi, Dave,

Sorry, you can't do it.

When you send the redirect, the request goes to the browser. The
browser is now responsible for fetching the new page. Your script is
no longer "in the loop".

Maybe you could do it with javascript - I haven't tried. But that
would have its own problems (i.e. user has disabled javascript).


Actually, what could be done is to check for a good response at new URL
with fsockopen() and if successful, do the redirect, otherwise go to the
alternate.

To the OP:
peruse the info here: http://us2.php.net/function.fsockopen

--
Karl Groves
http://karlcore.com
http://chevelle.karlcore.com

Accessibility Discussion List: http://smallerurl.com/?id=6p764du

Mar 28 '06 #4
Dave wrote:
Actually, what I ended up doing was to use curl to request a very small
graphic from the site.
Used curl timeout to control the redirect time and got just the header.

$timeout = 10;
$testurl = "www.example.co m/small.gif";

$ch = curl_init();
curl_setopt($ch , CURLOPT_HEADER, 1);
curl_setopt($ch , CURLOPT_NOBODY, 1);
curl_setopt($ch , CURLOPT_URL,$te sturl);
curl_setopt($ch , CURLOPT_RETURNT RANSFER,1);
curl_setopt($ch , CURLOPT_TIMEOUT , $timeout);
$source = curl_exec($ch);
curl_close($ch) ;

if ($source!="") // optionally I could have tested for HTTP status, 404,
301, etc.
$url = "http://www.example.com/";
else
$url = "http://www.example.net/";
header("Locatio n: $url");

Thanks to all who responded,

Dave
"Karl Groves" <ka**@NOSPAMkar lcore.com> wrote in message
news:Xn******** *************** ******@216.196. 97.136...
Jerry Stuckle <js*******@attg lobal.net> wrote in
news:Zs****** **************@ comcast.com:

Dave wrote:

Hi All,

Can anyone suggest a reliable solution to php redirect?:

header("Loc ation: $redir_url");
if the above times out in $timeout seconds
header("Loc ation: $alt_redir_url" );

Many thanks,

Dave

Hi, Dave,

Sorry, you can't do it.

When you send the redirect, the request goes to the browser. The
browser is now responsible for fetching the new page. Your script is
no longer "in the loop".

Maybe you could do it with javascript - I haven't tried. But that
would have its own problems (i.e. user has disabled javascript).


Actually, what could be done is to check for a good response at new URL
with fsockopen() and if successful, do the redirect, otherwise go to the
alternate.

To the OP:
peruse the info here: http://us2.php.net/function.fsockopen

--
Karl Groves
http://karlcore.com
http://chevelle.karlcore.com

Accessibili ty Discussion List: http://smallerurl.com/?id=6p764du



All this does is mean you can access it from your site at that time.

It doesn't mean, for instance, the user can access it - there may be a
communications problem somewhere between the user and the target site, for instance.

And of course there's the slight chance the site will go down between the time
you request the graphic and the time the redirect takes effect. But the odds of
that happening are pretty remote unless you're doing hundreds of redirects per
minute.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Mar 28 '06 #5
Jerry Stuckle wrote:

Maybe you could do it with javascript - I haven't tried. But that would have
its own problems (i.e. user has disabled javascript).


It can't really be done reliably in Javascript either, with cross-site
scripting restrictions keeping you from detecting the state of the
target site. All I think can of is to link to a image on the target
site, then check to see if its dimensions are corrected. That obviously
wouldn't work if the image happens to be sitting in the browser cache.

Mar 28 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
598
by: Grant | last post by:
Hi, I have searched the net and still no luck... I just want to automatically have a page redirected to another page when the timeout set in the config file expires. I currently have: <sessionState
0
1201
by: Ed Henn | last post by:
I'm having a problem with .NET Forms Authentication in a particular application. It's not redirecting properly when my session is timed out, seemingly only when I POST the page (i.e. click a form submit button). If I try to GET a page after timeout (i.e. just picking a page to visit from a menu), I am redirected to the login screen properly. The browser error I'm getting in the POST example is "403.1 Execute Access Forbidden". I...
6
7838
by: Weave | last post by:
I would like to redirect to a logout page after a session has timed out. I have placed a response.redirect "loggedoff.asp" in the Session_OnEnd subroutine in the global.asa, but it does not move to the page after timeout occurs. Any suggestions? Thanks in advance ....
2
5487
by: francois | last post by:
in my web.config i have the following : <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
10
7928
by: Anthony Williams | last post by:
Hi gang, This one looks like a bug :o( As you may or may not know, setting session management in web.config to use cookieless sessions causes the ASP.NET runtime to munge a session ID into the URL, in the format http://yourapplicationpath/(Session.SessionID)/... which saves numerous headaches when it comes to storing state across page requests and sessions.
1
2235
by: Danny | last post by:
Hi there, I was wondering if anyone would be able to shed some light on the following behaviour for me. I have an application that is using Forms Authentication with non-persistent cookies, a forms timeout of 10 minutes, and a FormsAuthenticationTicket Expiration of 10 minutes. Almost everything is working as expected... when users try to enter restricted parts of the site they are redirected to the login.aspx page that I have...
1
3595
by: Anders Jacobsen | last post by:
Hey Im devloping an application in asp.net 1.1 SP2. I need to control timeout values for each user. Im having trouble to make it work. When the session timouts out I want to redirect the user to the login page. OK., Im aware that we have 2 timeouts. Session timeout and forms authentication timeout. In login i do this
1
2243
by: Clare Strickson | last post by:
Hi Is it possible to redirect the user to a login page when the session has timed out? thanks in advance David Strickson
4
2549
by: shank | last post by:
I have a page that will timeout and crash with a timeout error on line 200. How can I do a redirect instead of the page halting if such an error does happen? thanks
0
8763
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9202
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8151
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.