Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Passing values between Apache SSIs

by atemon (Chaplain)
on Jun 02, 2008 at 07:58 UTC ( [id://689646]=perlquestion: print w/replies, xml ) Need Help??

atemon has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I dont know if this is a more Apache-related question but . . .

In the shopping cart I made recently, I have an HTML wit Server Side Includes like

<BODY> <!--#exec cgi="/cgi-bin/sessions.cgi"--> <!--#exec cgi="/cgi-bin/cart.cgi"--> </BODY>
where sessions.cgi is creating sessions if its NOT set already and cart.cgi is my program dealing with shopping cart. In some initial cases I need the session ID generated by sessions.cgi in cart.cgi, in the same request. Is there a way to pass values between SSIs?

Cheers !

--VC
Gods Own Country...

Replies are listed 'Best First'.
Re: Passing values between Apache SSIs
by moritz (Cardinal) on Jun 02, 2008 at 09:23 UTC
    You can't pass values from the first to the second script, because the first doesn't ever call the second script.

    Your best chance is to ensure that the user already has a cookie, then set up the session in session.cgi, store it in the DB, and retrieve it in cart.cgi. That probably defeats the purpose of the separation of the two scripts.

    So instead of using two SSIs, call a dispatch script that calls both scripts and passes the values from the first to the second.

      Hi,

      Thanks for your help. But I am using more SSIs in the HTML, where each SSIs are separated by loads of HTML. So I cant call them from a despatch script. Also, I have more HTMLs which have session.cgi, along with SSIs other than cart.cgi. I kept them together for demonstration purpose only.
      I will try setting cookies from session.cgi

      Cheers !

      --VC
      Gods Own Country...

        I will try setting cookies from session.cgi
        That won't work, because there are no new HTTP requests between the call to session.cgi and the other scripts. You can only access the session in all those scripts if the user already has a cookie.

        Your application sounds if it's hight time to switch to a decent template system (and perhaps a MVC framework) instead of HTML pages intermingled with SSI. I built pages like that (HTML + lots of SSI) in the past, and I found that the complexity of passing information around outweighs the seemingly simplicity that it offers at first.

        Your question demonstrates that HTML+SSI isn't very flexible when used like this, and it's really painful to extend and scale inflexible systems.

Re: Passing values between Apache SSIs
by Anonymous Monk on Jun 02, 2008 at 08:30 UTC

      Hi,

      I went through these documentations already. I didn't get any idea about how to do. Any monk, from their experience, can help me I hope.

      Cheers !

      --VC
      Gods Own Country...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://689646]
Approved by pc88mxer
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-26 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found