1

got high hopes seeing how well my first question was answered so I will try to word this as best I can but if you need anymore info just shout.

I have a site that I have built that works fine on all the different test servers we use, but is now on a client's server and a small bug has arisen that after searching around I understand why it is doing it, but not sure of the best way to fix it.

Basically on one of the page I have a php if statement to determine if the querystring is present, this code is below

<?php if (isset($_GET['area'])) { ?>
 <script type="text/javascript">
 $(function() {
 setTimeout(function() {
 $('#<?php echo $_GET['area']; ?>-popup').click();
 }, 500);
 });
 </script>
<?php } ?>

All works great on my servers, however on the client's this isset($_GET['area']) always return true. What it is doing is that when you go onto the page using the link that adds the ?area=test, the server is storing this value, and whenever I go back onto this page it thinks that the GET is true and then performs the popup, even though there is no querystring.

Very annoying, I was thinking of clearing the session perhaps but it seems overkill, is there an unset $_GET function that I could perform prior to checking if the query string exists.

Hopefully that made sense I've never had to do something like this before, it seems mad that a server would store $_GETS.

Thanks in advance.

Vishal
1,2341 gold badge9 silver badges16 bronze badges
asked Sep 6, 2012 at 9:16
6
  • You're right, this doesn't make sense .. Commented Sep 6, 2012 at 9:20
  • Is it possible that the server caches the output HTML rather than the querystring? Commented Sep 6, 2012 at 9:20
  • 1
    The server does not "cache $_GET". That would be idiotic and prevent any meaningful interaction with the server. Commented Sep 6, 2012 at 9:20
  • Just from the code ;) !! You did escaped the quotes in this line.. $('#<?php echo $_GET['area']; ?>-popup').click(); like $('#<?php echo $_GET[\'area\']; ?>-popup').click(); ?? Commented Sep 6, 2012 at 9:29
  • 1
    @dshai Not necessary, because PHP is evaluated separately from and before Javascript. He should JSON encode the value output by PHP though, as it may mess up the Javascript syntax. Commented Sep 6, 2012 at 9:34

3 Answers 3

2

This is impossible. There's no $_GET['parameter'] if 'parameter' is not in the url. If the isset() returns true, it is present in the url.

Either the browser caches the url WITH get parameter or you 'spoof' the parameter somewhere else.

answered Sep 6, 2012 at 9:21
Sign up to request clarification or add additional context in comments.

1 Comment

Hi Robin, got to the bottom of it. It was as you mentioned the server caching the html of the page to speed up load times but that was interfering with the variables on page load.
2

There is no cache for $_GET as long as I know.

Moreover, usually you'll set a random GET value to avoid server cache like ?seed=123131153131

Are you sure about the request you send to Php when displaying the page ?

answered Sep 6, 2012 at 9:20

Comments

2

$_GET does not get cached.

However, I can imagine you do a check somewhere with a single =.

Something like;

if ($_GET['area'] = 'test')

This will set it, and make it true. Thus you will always have it (and this if() will also be true in that case

answered Sep 6, 2012 at 9:24

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.