2

I've created an online store within an android app in webview but have one major problem...

When im processing my shopping cart i go to a php file, save the items in a session variable and then use the following to bounce back to the page i was just on...

Header('Location:' . $_SERVER['HTTP_REFERER']);

This works perfectly on the android browser but unfortunately does not work in webview... Does anyone know how fix or a workaround for this please

One thing is though that it does work if i specify a location such as

Header('Location: shop.php'); 

So it seems that its $_SERVER['HTTP_REFERER'] which does not work... can anyone help with a work around please...

kev670
  • 810
  • 2
  • 18
  • 37
  • 1
    `Header('Location: shop.php');` is wrong, location headers need to use [absolute URIs](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30) – Esailija Mar 27 '12 at 13:41

2 Answers2

2

Not all browsers send a 'referer' string with the request, I suspect webview is one of these.

You should include the url the previous page was on within the form that you submitted, then you can use this.

Al_
  • 2,479
  • 7
  • 29
  • 43
1

This are two ways which could work for you:

  1. Use a Javascript Redirect:
    <script type="text/javascript">window.location.href = "url";</script>
  2. Use a HTML Meta Tag:
    <meta http-equiv="refresh" content="0;url=http://webdesign.about.com/">

Those two examples can also be called later than just before the first script output. But remember that not all clients support this.

Community
  • 1
  • 1
evotopid
  • 5,288
  • 2
  • 26
  • 41