Forum Discussion

Joe_Hsy_45207's avatar
Joe_Hsy_45207
Icon for Nimbostratus rankNimbostratus
Apr 24, 2009

saving local vars across redirects?

Hi,

 

 

I'm trying to save some post parameters into a local var which survives across redirects back to the same vip. Currently, if the post results in a 302 response, the local vars appears to be cleared. I know can save it in a global var in some unique id that ties to the redirect, but I was wondering if there is some cleaner way which essentially extends the life of the local var.

 

 

Thanks!

 

 

//Joe

9 Replies

  • If the response which has a reference to the wrong location is being sent through LTM, you could rewrite the reference to avoid the bad request. You can do the rewrite using a stream profile and STREAM::expression iRule (Click here). The concept is similar to this post (Click here).

     

     

    Aaron
  • Hi Aaron,

     

     

    Actually, it isn't that redirects are wrong locations, but typical of when the POST is a sign-on and after successfully signing on, the website redirects the browser to another URL. I am trying to save some of the post parameters of the original sign-on to be available to at the redirected GET.

     

     

    As I understand it, local vars are tied to the "connection". Could I extend the connection specifically using iRules at specific POST requests and then end the connection?

     

     

    Thanks!

     

     

    //Joe
  • Hi Joe,

     

     

    I'm still not clear on what you're trying to do. Could you clarify tihis: "I am trying to save some of the post parameters of the original sign-on to be available to at the redirected GET."

     

     

    Thanks,

     

    Aaron
  • Hi Aaron,

     

     

    Sorry if I didn't make it clear. The example is where the POST request is from a sign-on page with post paramters containing info for the signon (e.g. username, etc). The response on success is a 302 redirecting to a welcome page, which is a GET. I would like to save some of the post parameters in a local var and have that var still be available when the welcome page GET request comes in. Hope that makes it a bit more clear!

     

     

    Thanks!

     

     

    //Joe
  • I don't think you could force the client to re-use the existing TCP connection to send the GET request following the redirect. What about appending the parameters to the redirect Location header so the client submits them in the subsequent request? Another option might be to append a Set-Cookie header to the redirect response with the parameter name / values.

     

     

    Aaron
  • Thanks, Aaron. Yes those are all possible though it is preferred not to alter the redirected GET request in any way be it in the URL or cookies. I will go with the global var and make sure to clean it up. Any best practices for cleaning up global vars?

     

     

    Thanks!

     

     

    //Joe
  • Hi Joe,

     

     

    If you don't want to modify the response sent to the client you could store the data in the LTM session table using the session command (Click here). The advantage to this over a global array is that LTM will provides a timeout option for entries. So you don't hvae to worry about trying to clean up stale entries. If you have multiple clients connecting from the same IP addresses, you could use the client IP and the user-agent header value as a combined key to store the session data.

     

     

    Aaron
  • Hi Aaron,

     

     

    Thanks for the great suggestion regarding the LTM session table. I wasn't aware of this capability and it looks to be a good fit for what we need.

     

     

    Thanks again for all your help!

     

     

    //Joe