SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Wizard bronze trophy Tailslide's Avatar
    Join Date
    Feb 2006
    Location
    Bedford, UK
    Posts
    1,687
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Page expiring and back buttons

    Hi all

    I'm slightly confused (as per normal) and wondering if you could help.

    I have a page - let's call it advice.php.

    When a user clicks a link on that page it goes to an intermediary checking page which checks which link they want to go to, records their visit in the DB and then sends them to the requested page is on external sites.

    That page is called checklinks.php.

    Trouble is when users are on the external page and hit back button they get the expired page warning in IE (and re-send page warning in FF).

    I've tried adding

    PHP Code:
    ini_set('session.cache_limiter''private'); 
    to the checklinks.php page which I thought was working but I seem to occasionally get a repetition of the problem.

    What's the best way around this and have I added that ini_set() to the right page - should it have been on the advice.php page (the original page).

    Thanks
    Little Blue Plane Web Design
    Blood, Sweat & Rust - A Land Rover restoration project

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    If I follow, you're basically implementing the POST/Redirect/GET Pattern, but without the POST.

    Page.php -> Logger.php -> Target

    I always thought you just have to send the right HTTP code for this to work?
    PHP Code:
    header('HTTP/1.1 303 See Other');
    header('Location: http://www.somesite.com/');
    exit; 
    Edit: Yup, just tested here FF3 and all seems good.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check which actual http headers get sent on that page. An easy way is to use a browser addon like http live headers or firebug for firefox.

  4. #4
    SitePoint Wizard bronze trophy Tailslide's Avatar
    Join Date
    Feb 2006
    Location
    Bedford, UK
    Posts
    1,687
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes it's one of those things that's hard to explain - the basic idea is that the client is passing leads onto another company and needs to keep track of where the people that use the site are going - they have passwords which enable them to log in and once logged in they can then access the links to the other companies.

    The links go to the checking page and have the particular company id appended to them.

    The checking page makes a note of the user and where they're going and then redirects them according to the supplier id appended to the URL of the link on the first page.

    Does that make sense?
    Little Blue Plane Web Design
    Blood, Sweat & Rust - A Land Rover restoration project

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds a lot like what I do at http://linktrack.info.

    Here's how I approach it:

    Use a tracking hash on each link and have your redirect page look for it in the url and check for it in the database of links.

    If it's a valid link, record the visit in the database and use php header() to foward them to the proper location.

  6. #6
    SitePoint Wizard bronze trophy Tailslide's Avatar
    Join Date
    Feb 2006
    Location
    Bedford, UK
    Posts
    1,687
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Keeton

    Is there an advantage in hashing the link identifier bit as opposed to just having an id in the url which checks against the db and re-directs? Would it stop the expired page thing?
    Little Blue Plane Web Design
    Blood, Sweat & Rust - A Land Rover restoration project

  7. #7
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Morning Tailslide,

    Does my offering not suit?

    I tried it here and did not receive any expired page notices, are you POSTing to the intermediate page or simple passing an id via GET?

    HTML
    Code HTML4Strict:
    <a href="redirect.php?id=1">Visit</a>

    PHP(redirect.php)
    PHP Code:
    <?php
    $aSites 
    = array(
        
    'http://www.google.co.uk',
        
    'http://www.yahoo.co.uk',
        
    'http://news.bbc.co.uk',
        
    'http://www.telegraph.co.uk/scienceandtechnology/science/sciencenews/',
    );
    if(isset(
    $_GET['id']) && !empty($_GET['id']) && isset($aSites[$_GET['id']]))
    {
        
    header('HTTP/1.1 303 See Other');
        
    header(
            
    sprintf(
                
    'Location: %s',
                
    $aSites[$_GET['id']]
            )
        );
        exit;
    }
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  8. #8
    SitePoint Wizard bronze trophy Tailslide's Avatar
    Join Date
    Feb 2006
    Location
    Bedford, UK
    Posts
    1,687
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Anthony

    Been out of the office so haven't had a chance to try it!

    I'll give it a go this morning and see if I have any joy.

    Thanks for your help.

    this is a shortened version of my script with your header bit added in - does it look right?

    PHP Code:
    if($_GET['supplier_id'])
    {
    $supplier_id=$_GET['supplier_id'];

    ... 
    other bits retrieving supplier link url from db and adding stuff to db about the person clicking through ...

    header("Location:"$sup_link);
    header('HTTP/1.1 303 See Other');


    Little Blue Plane Web Design
    Blood, Sweat & Rust - A Land Rover restoration project

  9. #9
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Switch-a-roo those header calls and you're good to go I'd say.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  10. #10
    SitePoint Wizard bronze trophy Tailslide's Avatar
    Join Date
    Feb 2006
    Location
    Bedford, UK
    Posts
    1,687
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool - thanks. Having the day from hell at the moment but will get this done asap and let you know.
    Little Blue Plane Web Design
    Blood, Sweat & Rust - A Land Rover restoration project

  11. #11
    SitePoint Wizard bronze trophy Tailslide's Avatar
    Join Date
    Feb 2006
    Location
    Bedford, UK
    Posts
    1,687
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm... odd...

    It's still happening, but only on the first "clickthrough" once logged in. Far as I can see it doesn't repeat itself after that. But if I logout and log back in - again the first link I try, when I then hit "Back" I get the expired webpage warning.
    Little Blue Plane Web Design
    Blood, Sweat & Rust - A Land Rover restoration project

  12. #12
    SitePoint Wizard bronze trophy Tailslide's Avatar
    Join Date
    Feb 2006
    Location
    Bedford, UK
    Posts
    1,687
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are there any other suggestions with this problem as I have to see the client later on today!

    Thanks for your patience.
    Little Blue Plane Web Design
    Blood, Sweat & Rust - A Land Rover restoration project


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •