Re: Persistent state applications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ive starting using Pear cache_lite(). Works great for maintaining stuff between page refreshes. You can set the retention time to anything reasonable.

tedd wrote:
At 12:34 PM -0700 5/17/08, James Colannino wrote:
Hey everyone! I'm very new to PHP, and had a somewhat general question (forgive me if it's too broad in scope.) Basically, I'd like to be able to have a single PHP application that remembers its state as users click on links. When the user clicks on a link, though, the user unavoidably re-requests the URL from the web server, which forces the PHP application to reload. I'm therefore uncertain as to how I should keep the program in a state in which it remembers things like login information when the users have to click on links in order to navigate the application.

This is especially an issue for me when it comes to maintaining things like persistent connections to SQL servers.

Thanks!

James

James:

There are several ways to do what you want. You can store your variables in:

1. A $_SESSION variable;

2. A $_COOKIE variable;

3. A $_POST variable;

4. A $_GET variable;

5. A field in MySQL dB;

However, all (1-5) of those via php will require a page refresh to send them on to the next page and for the next page to read them in again. IOW, to read back in the variables in whatever form.

6. If you use javascript, then you can use your variables (client-side) and then send them to php when you're ready to use them server-side -- of course that's after validation and it again requires a page refresh.

7. You can combine ajax (javascript with a "behind the scenes" communication with the server) and php to produce a page that doesn't refresh, but the page keeps it's state.

However, with (6-7) your web page will require javascript to be turned ON by the user and a significant number of users (~10%) don't have js turned ON.

So there are several ways, but each has it's trade-offs.

Cheers,

tedd

PS: Gang -- if I have missed one, please jump in and correct me.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux