pritam79 Posted August 24, 2010 Share Posted August 24, 2010 Which method is the most common, safe, secure, reliable and appropriate to use in order to pass the variables between PHP pages- Using variables in the URL, Through a session, Via a cookie or with an HTML form? Link to comment Share on other sites More sharing options...
boen_robot Posted August 24, 2010 Share Posted August 24, 2010 For what purpose? Under what conditions must the data be preserved? There's no single best way to use any of the things you mention. They all have their place, but for different purposes.Session is best used for estabilishing "per user connection" information, which will often be preceded by a log in. This forum for example uses a session variable to keep track of the current page you're on. The session cookie itself helps identify if you have the rights to view/edit/create whatever it is you're viewing/editing/creating.Cookie is best used for estabilishing non-critical per computer preferences. Some sites for example use cookies to store language and theme preferences. They do so instead of sessions to avoid making users log on, and make the preferences valid for longer periods of time while still letting actual users log in securely.POST (form) data is best used for data that is entered NOW, and must be acted upon NOW, and only ONCE. For example, when you post a reply, you're posting via the POST method.GET (URL) data is best used for data that has been entered NOW, but must be acted upon NOW and EVERYTIME the equivalent data is entered. For example, to refer back to this topic, this forum uses a URL variable that specifies the forum topic to load. Link to comment Share on other sites More sharing options...
ShadowMage Posted August 24, 2010 Share Posted August 24, 2010 They are all equally common, safe, secure, reliable and appropriate depending on their context and what you'll be using the data for.Edit: See boen_robot's post above. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.