PHP and JavaScript Interaction: Storing Data in the Client, part 1

Certainly the concepts have been covered repeatedly in countless articles, books or papers you can imagine, digging into the territory of Web development: server-side and client-side programming... In most situations, this interaction is bi-directional. You might see either server-side languages, such as PHP, generating client-code, that means JavaScript/(X)HTML, or JavaScript functions building up data to be processed in the server. Either way, the process is often a two-way street. Particularly, if we take into consideration the first half of the equation, where PHP (or the server-side language of your choice) performs some kind of quick client-program generation, we rapidly end up storing some temporary data directly in the client computer's memory.

We'll demonstrate how to use this approach to store data in the client and noticeably reduce the client-server transferring process, developing a couple of applications useful for implementation on any project of your choice. Let's get ready to try out a combination of PHP and JavaScript.

Of course, here we're discarding any other well-known client-side storage process, such as cookies, image-based data tracking, data coming in from local cached files or even from XML files. This issue immediately brings to mind a question that has caused several heated discussions: is it good to store data in the client this way? The range of opinions varies widely from a rough complaint to a resounding yes. The truth is that the answer is hard to give, since it relies strongly on several factors, such as amount of data, type, user hardware (remember we're using client system resources) and particularly data relevance.

Definitely, we'll agree that no critical data will be stored in the client, even if this sounds like common sense stuff. If you ever thought that critical information should be stored in the user's environment, please change your mind right now! However, regarding my personal experience, when building applications that heavily eat up a client's computer resources, difficulties can easily appear, causing browser crashes or complete system hangs.

But, all is not lost. As hardware rapidly evolves, and it's widely available to average users, there are certain cases where it is possible and even desirable to have a small application directly using the client's memory to store temporary data.

Chris Charlton

Chris CharltonChris, Los Angeles' CSS & ActionScript guru, successfully cannonballed into web development in the late 90's. Always caught up with the latest in Flash, Dreamweaver, Fireworks, and XML, Chris authored premium articles for the largest Dreamweaver/Flash community (www.DMXzone.com) and produced WebDevDesign (iTunes featured), a popular Web Design & Development Podcast. Somewhere, Chris finds time to run an authorized Adobe user group focused around open source and Adobe technologies. Being a big community leader, Chris Charlton remains a resident faculty member of the Rich Media Insitute and lends himself to speak at large industry events, like JobStock, NAB, and FITC Hollywood.

Brain cycles from Chris are always Web Standards, Flash Platform, and accessibility.

See All Postings From Chris Charlton >>

Comments

Be the first to write a comment

You must me logged in to write a comment.