Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Changing website prices based on client? (keywd: Web Software Engr)

by princepawn (Parson)
on Jun 07, 2001 at 20:56 UTC ( [id://86651]=perlquestion: print w/replies, xml ) Need Help??

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

I work at a major company and we get discounts from the major internet vendors. The thing that amazes me is if you go to the site from the outside of Oracle, it looks like a normal site.

But, when I visit the site from work via a popup, all the prices in the whole website are discounted by 5 percent.

What would you say is the best way to support this sort of customization?

  • Comment on Changing website prices based on client? (keywd: Web Software Engr)

Replies are listed 'Best First'.
Re: Changing website prices based on client? (keywd: Web Software Engr)
by knobunc (Pilgrim) on Jun 07, 2001 at 21:49 UTC

    Well you have to decide how you are going to determine if they are from the appropriate place. You have a couple of choices:

    1. Check the REMOTE_ADDR environment variable (set by standard CGI and mod_perl, there are other ways to get it for different web apps), do a reverse look up on it and check the domain
    2. Have some token they use to ID which discount applies then either keep it as a hidden on all pages, store it on the server side session info for the user or set a cookie

    Choice 1, relying on the DNS name:

    use Socket; my $remote_addr = $ENV{REMOTE_ADDR}; my $remote_host = gethostbyaddr(itet_aton($remote_addr), AF_INET); if ($remote_host =~ /\.oracle\.com$/) { # Do whatever }

    Implementing choice 2 is up to you since it is very dependent on the code you are using.

    The advantage of the first is that there is not much you have to do to get it to work since the hostname should not change over the course of the transaction. With the second you have to store the token somewhere so that you can access it on each request. Depending on the infrastructure you have in place, that may be easy.

    Where the second choice wins is that it is possible that not all IP addresses have a reverse lookup even if they are all in Oracle's domain. Also people may be accessing Oracle mail through a VPN so the discount would not apply to them. If you have a special token then this does not matter since the token applies no matter where they come from. Also you can use the same mechanism for promotional purposes where you issue a discount 'coupon' if they do something. The obvious downside is that people can mail the tokens around so other people may get the discount.

    -ben

      One of the cuter variations on this was a company a few years back that checked $ENV{'REMOTE_ADDR'} for incoming requests to their home page, and spit back a special "We're Hiring" page for requests that came from competitors.

      A couple of things:
      1. REMOTE_ADDR and REMOTE_HOST can be modified by the user. There is no guarantee that the value transmitted for these variables is correct. Therefor, these can be abused by someone attempting to gain improper discounts.
      2. Storing an ID as a hidden on a page again leaves you open for abuse. This relates strongly to the recent rash of poorly written shopping cart systems being abused. The prices were being "hidden" in the HTML, all a would be abuser needed to do was: Save the HTML, change the price, hit the button -- Wallah! Pay $1.00 for a $100.00 item. Storing an ID for discount could be similarly abused.
      3. Storing ID in a cookie, should be combined with sessioning to help avoid abuse. If the cookie value is indexed in such a way that it is only good for a period of time, the chance for abuse is limited. Possibly linked to IP or other identifying information as well, to make transference of the cookie ID to a different machine more problematic. This type of solution will probably lead you to have to "re-authenticate" the user periodically based on some business rules regarding latentcy and/or total visit time.
      Please do not fall into the trap of believing a piece of sensitive data in a "HIDDEN" form field is secure or tamper-proof -- it simply is not, and has been abused significantly, regularly, and recently.

        Good points. I guess I should have mentioned more about security of each method.

        REMOTE_ADDR and REMOTE_HOST are pretty safe since they come from the sockaddr struct that relates to the connection, so you are somewhat succeptible to a man-in-the-middle attack if the sender can spoof the IP address and catch the return packets (assuming that there is no TCP sequence number bug that allows him to predict the excact set of packets to send from elsewhere). Of course you are succeptible to a DNS attack if the attacker can spoof the reverse IP address lookup, and DNS is notoriously unsafe.

        Storing the ID on each page is relatively safe iff (sic) the discount ID refers to a token ID stored in the DB that is generated randomly (assuming your random number generator is sufficiently random) from a large search space. Really cookies and hidden form variables are equivalent since they are both submitted on each request and the user can munge them both. Since this is discounts you have to decide if you want the user to log in to the site.

        Personally I despise logging in until I am actually ready to order. It might be more productive for a site to give a 5% discount to a handful more people if they get more sales in general. Remember that stores often see 30 - 60% markups so they are making a profit even if they offer substantial discounts.

        -ben

Re: Changing website prices based on client? (keywd: Web Software Engr)
by shotgunefx (Parson) on Jun 08, 2001 at 02:15 UTC
    It depends on how your discounts are implemented and who your clients are.

    Resellers for instance... In my personal experience with business, most products are usually grouped into different classes and different resellers get different pricing levels.

    In this situation, a login via username and pass would be best. Otherwise if people even only occasionally see what someone else is paying, it will cause huge headaches.

    -Lee

    "To be civilized is to deny one's nature."
Re: Changing website prices based on client? (keywd: Web Software Engr)
by Sifmole (Chaplain) on Jun 07, 2001 at 21:02 UTC
    Princepawn,
    At a previous gig, we had a client table which listed a discount. Each product price was then modified by the discount before presentation; Pretty straight forward.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-19 19:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found