in reply to Re^2: HTML Template
in thread HTML Template
You have to do this, not the server. Imagine user A is looking at a web page. On that web page, it says, "Hello user A", which is a result of a template, say, welcome.tmpl, which says "Hello user <TMPL_VAR USERNAME>", which, in turn, is filled by a script, say, query.cgi, which queries a data store $tmpl->param(USERNAME => $self->getuser).
Since query.cgi was called by user A, which caused welcome.tmpl to be filled with the retrieved values and sent back to user A, user B can never see what user A requested. This is because the web is stateless. One query does not know from another, even from the same user, let alone from different users. Unless...
Unless, user A is requesting something that is held in the server's memory. This is where things get screwy. This is where the concept of sessions comes in. Somehow, you, the programmer, has to ensure that the web server "remembers" who is requesting what. The web server can't do that on its own. You have to do something to make this happen. An excellent way to do that is by using a module such as CGI::Session, or CGI::Application::Plugin::Session, essentially a wrapper around the former.
Using sessions, you utilize a cookie (or a URI parameter) to make one request be connected to a previous request. Then you utilize that connection to make sure you are getting the correct data back for the user that has requested it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: HTML Template
by Anonymous Monk on Jun 14, 2010 at 00:09 UTC | |
by punkish (Priest) on Jun 14, 2010 at 03:16 UTC | |
by Anonymous Monk on Jun 14, 2010 at 03:22 UTC | |
by punkish (Priest) on Jun 14, 2010 at 05:36 UTC | |
by Anonymous Monk on Jun 14, 2010 at 07:55 UTC |