What\'s the difference when using GET
or POST
method? Which one is more secure? What are (dis)advantages of each of them?
(similar question
Get and Post methods have nothing to do with the server technology you are using, it works the same in php, asp.net or ruby. GET and POST are part of HTTP protocol. As mark noted, POST is more secure. POST forms are also not cached by the browser. POST is also used to transfer large quantities of data.
GET
and POST
are HTTP methods which can achieve similar goals
GET
is basically for just getting (retrieving) data, A GET
should not have a body, so aside from cookies, the only place to pass info is in the URL and URLs are limited in length , GET
is less secure compared to POST
because data sent is part of the URL
Never use GET
when sending passwords, credit card or other sensitive information!, Data is visible to everyone in the URL, Can be cached data .
GET
is harmless when we are reloading or calling back button, it will be book marked, parameters remain in browser history, only ASCII characters allowed.
POST
may involve anything, like storing or updating data, or ordering a product, or sending e-mail. POST
method has a body.
POST
method is secured for passing sensitive and confidential information to server it will not visible in query parameters in URL and parameters are not saved in browser history. There are no restrictions on data length. When we are reloading the browser should alert the user that the data are about to be re-submitted. POST
method cannot be bookmarked
I use GET when I'm retrieving information from a URL and POST when I'm sending information to a URL.
Use GET method if you want to retrieve the resources from URL. You could always see the last page if you hit the back button of your browser, and it could be bookmarked, so it is not as secure as POST method.
Use POST method if you want to 'submit' something to the URL. For example you want to create a google account and you may need to fill in all the detailed information, then you hit 'submit' button (POST method is called here), once you submit successfully, and try to hit back button of your browser, you will get error or a new blank form, instead of last page with filled form.
The best answer was the first one.
You are using: