Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 5 of 5

Thread: Retrieving CustomerID based on Session

  1. #1
    Draggor is offline Junior Member
    Join Date
    May 2007
    Posts
    5

    Exclamation Retrieving CustomerID based on Session

    Hi there,

    I am trying to create a custom download script that checks if a user has purchased a download, and if so, streams the file over to them.

    In order to check if a customer has purchased a product, I need their CustomerID. I somehow have to look up their CustomerID from the CustomerSession table. The only problem is I don't know how to get the appropriate Session GUID to look them up.

    In my custom .aspx page, I tried to use Session.SessionID - however this value is not a valid GUID, and thus cannot match the CustomerSessionGUID value in the CustomerSession table.

    So how on earth do I get the CustomerID based on what I have in the user session?

    Much appreciated,
    -Rob

  2. #2
    Draggor is offline Junior Member
    Join Date
    May 2007
    Posts
    5

    Default Found the Solution

    Hey Damien, thanks for the tip, I figured it out.

    The page must inherit from the SkinBase class, and then you can invoke ThisCustomer.CustomerID to get the Customer ID.
    Last edited by Rob; 05-16-2007 at 07:11 PM.

  3. #3
    DanV's Avatar
    DanV is offline Ursus arctos horribilis
    Join Date
    Apr 2006
    Posts
    1,568

    Default

    Hi Draggor,

    There really is a much better way to do this too Whenever a customer purchases a product we assign them a "Role" that is equal to the product SKU that was purchased. Some simple code like this would parse through all of the roles and determine if they can download the product or not...


    Code:
                Boolean CanDownload = false;
    
                if (ThisCustomer.Roles.Length != 0)
                {
                    String[] Roles = ThisCustomer.Roles.Split(',');
                    foreach (string s in Roles)
                    {
                        if (s == "sku for product I am protecting here")
                        {
                            CanDownload = true;
                        }
                    }
    
                    if (CanDownload)
                    {
                        //Do stuff here
                    }
                }
    Obviously you could pass in the SKU you are protecting dynamically instead of hardcoding into the file.

    Last edited by DanV; 05-16-2007 at 09:07 PM.

  4. #4
    virtualtap is offline Senior Member
    Join Date
    May 2007
    Posts
    171

    Default

    Dan, what do you mean by "role" and where do I find that in the DB?

    Thanks
    MSX

  5. #5
    AspDotNetStorefront Staff - Scott's Avatar
    AspDotNetStorefront Staff - Scott is offline Administrator
    Join Date
    Mar 2007
    Location
    Ashland, OR
    Posts
    2,390

    Default

    We don't actually store those roles, we look through the Orders_ShoppingCart table to see if a customer's bought a specific product when necessary.