473,883 Members | 1,787 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 19419
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
1205
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
7850
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
5495
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
7953
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
2239
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
3599
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
2246
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
2550
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
9944
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11153
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10757
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10420
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9583
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
7975
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
6002
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4225
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3239
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.