no coockie and proxy user redirect

Started on the old forum in March 2012 · view the original in the archive · old links redirect here

#htaccess #nocoockie #php #proxy #redirect

4 replies · 512 views · started 14 years ago · 1 min read

4 participants
haraldl Junior · 33 posts #1

hi coding talk!

i´m seraching for the best solution to redirect browsers wich : -accept no coockies

  • use proxy

any elegant solution ?

something else Fellow · 2,296 posts #2

I like rapidshares Proxy redirection setup that redirects web proxys to there site without the proxy... im guessing it is done on finding out what the url is but im unsure how you go about redirecting it to same page without the web proxy being used

for your answer:

//code removed as incorrect .... use gums code below :P

at a guess on web proxys:

if($_SERVER['REQUEST_URI']!="your file path")
{
 header("Location: http://yoursite.con");
exit;
}
GumSlone Administrator Principal · 1,690 posts #3

for proxy, the example by something else if also good for some web proxies

if ($_SERVER['HTTP_X_FORWARDED_FOR'] || $_SERVER['HTTP_X_FORWARDED'] || $_SERVER['HTTP_FORWARDED_FOR'] || $_SERVER['HTTP_VIA'])
{
    header('Location: http://yoursite.com');
}

and for cookie first of all set cookie for example on index page add after <?php:

setcookie("your_cookie_name", 1, time()+3600);  /* expire in 1 hour */

on subpages add this:

if (!isset($_COOKIE['your_cookie_name']))
{
    header('Location: http://yoursite.com/index.php'); /* if no cookie set, redirect back to index (all browsers which dont support cookies will be redirected to the index page all the time */
}

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

arnage Lead · 811 posts #4

Just was thinking is something like that would be better that something like this but i didn't know what globals they send. Thanks. 🙂

$host_ip = gethostbyaddr($ip);
if (strcmp($ip, $host_ip) == 0) {
echo 'Proxy';
}
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
haraldl Junior · 33 posts #5

I like gums solution.many proxy servers use x_forwarded_for . to try to give a coockie and request this , is a nice solution. thank you gum.i will setup this.

GumSlone wrote: for proxy, the example by something else if also good for some web proxies

if ($_SERVER['HTTP_X_FORWARDED_FOR'] || $_SERVER['HTTP_X_FORWARDED'] || $_SERVER['HTTP_FORWARDED_FOR'] || $_SERVER['HTTP_VIA'])
{
    header('Location: http://yoursite.com');
}

and for cookie first of all set cookie for example on index page add after <?php:

setcookie("your_cookie_name", 1, time()+3600);  /* expire in 1 hour */

on subpages add this:

if (!isset($_COOKIE['your_cookie_name']))
{
    header('Location: http://yoursite.com/index.php'); /* if no cookie set, redirect back to index (all browsers which dont support cookies will be redirected to the index page all the time */
}

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close