Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2006
    Posts
    4
    Plugin Contributions
    0

    Default Passing parameters

    hello,

    I have a stupid question, I dint find an answer yet.
    What is the best way to pass parameter from on site to another

    for example shopping_cart to checkout_shipping should i do it over post or get and how or should i write it to variable and reed it later?

    Don't know what is best practice

    thx and Greetings

  2. #2
    Join Date
    Sep 2004
    Posts
    1,388
    Plugin Contributions
    4

    Default Re: Passing parameters

    You said from "one site to another," as in across two differing domains? If that's the case, step one is to make damn sure you're not passing sensitive material, as both GET and POST will transmit unencrypted.

    That being said, both have the same basic function, there are just a few key differences between GET and POST that will typically make the decision for you.

    First, GET variables are actually listed in the URL. So if you don't want a long address line, don't use GET. However, having all the variables in the address line makes it very easy to generate a link with necessary accompanying variables, and/or to redirect a page after processing (search for "zen_get_all_get_params" in the Developers Toolkit for examples).

    POST variables, on the other hand, are stored in the header contents of the submitted page, so they don't appear in the URL. This makes it a lot cleaner, especially with lots of variables. You can also transmit arrays in POST; not possible with GET.

    Downside is that you can't do the simple redirection you can with GET (as they require a standard HTML form and a submission action). It's also tougher to see your variable values at runtime (to see GET just look at the address line, but POST doesn't appear in the HTML source output).

    Personally, I like POST, because it makes cleaner URL's and I have developer tools that allow me to look up the POST variables when I'm debugging. But if I have a page where I only ever have one or two variables, I'll use GET just for ease of use and tweaking.

    Hope that helps.
    Frank Koehl
    "Cleverly Disguised as a Responsible Adult"

    frankkoehl.com

  3. #3
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: Passing parameters

    I have a stupid question
    I think this is not a stupid question *at all* :-) Often it's not easy to decide which one is best to use.

    And I agree with BlinSide, of course :-)

    Information that you want to store "a little longer" (as long as the session is alive) you can also add to $_SESSION. That way you can pass the data across multiple pages without reposting the data on every page switch.

    You can also think about what data you would like to be visible for users ($_GET) or not ($_POST). For example: visitors can bookmark $_GET data, but can't bookmark $_POST data.

    note: both $_POST and $_GET paramaters can be manipulated by the user, so you always need to validate the data!

    And, don't ask me any numbers, but $_POST also can hold more data than $_GET.

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    10,527
    Plugin Contributions
    127

    Default Re: Passing parameters

    I wasn't sure of your meaning either - did you mean one page on one site to another page on another site? Or one page on one site to another page on the same site. (I'm asking because you referred to shopping cart to checkout shipping, which is normally just a matter of pressing the "checkout" button, and sounds like the latter). For the former, you can embed information in a url; for the latter, look at _SESSION.

    Scott
    That Software Guy. My Store: Zen Cart Support
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  5. #5
    Join Date
    Oct 2006
    Posts
    4
    Plugin Contributions
    0

    Default Re: Passing parameters

    thx guys

    this was what I wanted to hear !

    I stay in the same Domain and decided myself to use the _Session method because it is the easiest way in my case.

  6. #6
    Join Date
    Sep 2004
    Posts
    1,388
    Plugin Contributions
    4

    Default Re: Passing parameters

    Session definitely has a lot of advantages, you just have to be careful with how you name your variables. You don't want to override any pre-existing variables, and can cause pages to do whacky things to happen on pages where the values are unexpected.

    Just keep them on a tight leash and they'll work wonderfully.
    Frank Koehl
    "Cleverly Disguised as a Responsible Adult"

    frankkoehl.com

  7. #7
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: Passing parameters

    Exactly.

    I.e.:
    Code:
    $_SESSION['whateverthemodsnameis']['varname'] = 'varvalue';
    This way you only need to rename "whateverthemodsnameis" if it causes conflicts. Which is very unlikely of course, depending on what you use for "whateverthemodsnameis".

  8. #8
    Join Date
    Sep 2004
    Posts
    1,388
    Plugin Contributions
    4

    Default Re: Passing parameters

    Good point, Paul. That's exactly what I do, I don't know why I didn't think to mention it. Thanks for picking up my slack.
    Frank Koehl
    "Cleverly Disguised as a Responsible Adult"

    frankkoehl.com

 

 

Similar Threads

  1. passing parameters from poduct info page to shopping cart.
    By gmartakis in forum General Questions
    Replies: 11
    Last Post: 3 Jul 2013, 05:06 AM
  2. coupon parameters
    By w2e in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 1
    Last Post: 3 Nov 2007, 03:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg