1

suppose that I have two pages ( A and B ) , and I want to pass insensitive data from A to B , why I shouldn't set a query string variables containing my data in the target page URL(B) , and then retrieve my data from there using javascript (window.location.href) too , I mean why I should use PHP $_GET array ?

9
  • Because Page A no longer exists when you get to page B Commented Jul 27, 2015 at 15:43
  • You can also use cookies / localstorage in theory. Commented Jul 27, 2015 at 15:45
  • php is server side, javascript is on client side.. Thumb rule- be it sensitive or insensitive data, use server side implementation for retrieving and changing..! Commented Jul 27, 2015 at 15:46
  • 2
    @mahmoudnezarsarhan You can definitely use js.. it's more about perception, style and taste of your programming/coding(keeping this question in context). You can pass data using js or use server side implementation, it's up to you. However why server side should be preferred is because of security reasons, javascript can be modified at run time. But as you have stated the data is insensitive, you can absolutely go ahead with using js, if you feel comfortable with it Commented Jul 27, 2015 at 16:00
  • 1
    @SudhansuChoudhary thank you for this clear answer please put it as an answer so other people can make use of it in future ♥ Commented Jul 27, 2015 at 20:23

1 Answer 1

2

Putting my comments as the answer as suggested by OP,

php is server side, javascript is on client side.. Thumb rule- be it sensitive or insensitive data, use server side implementation for retrieving and changing..!

You can definitely use js.. it's more about perception, style and taste of your programming/coding(keeping this question in context). You can pass data using js(URLs as you have mentioned) or use server side implementation, it's up to you. However why server side should be preferred is because of security reasons, javascript can be modified at run time. But as you have stated the data is insensitive, you can absolutely go ahead with using js, if you feel comfortable with it.

And as @MonkeyZeus has commented, you could end up with ugly, long URLs. Especially if you have space(s) within a String that you are trying to pass as the data. It could look messy with (%20)s and stuff being added in the URL.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.