How to read ShopSite sbid cookie / session file

General ShopSite user discussion

How to read ShopSite sbid cookie / session file

Postby b2tech » Fri Oct 21, 2011 10:05 am

Hello,

I'm using a custom cart for displaying a dynamic list of products and passing the values to shopsite via ajax to checkout / add to cart. It works well.

I now want to check quantities for products before adding them to the cart. I thought I'd be able to do this by simply reading the "ss_cart_0001238012" cookie. Not so easy, the "ss_cart_0001238012" cookie doesn't include my product skus so I can't properly check the correct quantity available against what's in the cart. (I need to use unique skus for each product listed on the page)

After searching the forums and other resources I've found that the "sbid" cookie value "SSMSB1234123496.25001" points to the session data which includes all the cart data (hopefully the skus too..).

How would I go about accessing this information (using php / javascript)?

I really just need to know if there's a specific path to the session data store location / tmp path? Is it stored in the database file? I searched my cgi-bin/sc ande cgi-bin/ss directories but found nothing related to the sbid value.
b2tech
 
Posts: 21
Joined: Tue Aug 03, 2010 2:51 pm
Location: MN

Re: How to read ShopSite sbid cookie / session file

Postby b2tech » Fri Oct 21, 2011 10:17 am

Ok I think I found the cookie storage location, this may vary depending on your shopsite install (version 8.3).

After some find commanding I was able to get the location

Code: Select all
[/home/my_dir]# find /home/my_dir/ -name SSMS*

/home/my_dir/ssdata/ip/SSMSB5555555555.55555
/home/my_dir/ssdata/ip/SSMSB5555555555.55555
etc...


Now I just need to open / read the files and pull out each product's sku / quantity
b2tech
 
Posts: 21
Joined: Tue Aug 03, 2010 2:51 pm
Location: MN

Re: How to read ShopSite sbid cookie / session file

Postby Jim » Fri Oct 21, 2011 11:03 am

The data in the shopping cart files is in a proprietary database format and is not directly readable without using the ShopSite cgis. Some of the information is encrypted, so even if you could read it you would not be able to decipher what it is.

Note that cookies are stored on the shopper's browser not as files on a server. The cookie is used to indicate to the ShopSite shopping cart cgi which shopping cart file belongs to that particular shopper.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: How to read ShopSite sbid cookie / session file

Postby b2tech » Fri Oct 21, 2011 12:36 pm

Thanks for the explanation.

So is there any way to get skus / quantities for products currently in the cart if the skus are not stored in the standard 'minicart' cookie?
Or is there a better approach?

I also tried making an ajax request to the cart to try and load the ss_sku and ss_quantity arrays but haven't had success yet. I ran into issues trying to access the 'sbid' cookie with javascript...

Thanks for any info.
b2tech
 
Posts: 21
Joined: Tue Aug 03, 2010 2:51 pm
Location: MN

Re: How to read ShopSite sbid cookie / session file

Postby Jim » Fri Oct 21, 2011 1:52 pm

There are javascript variables assigned with values of the products in the cart, including sku, which you should be able to access (I don't know how you would do that from outside the cart itself) They are listed in the help at
http://www.shopsite.com/help/11.0/en-US/sc/pro/cart.variables.html If you have a previous version of ShopSite replace the 11.0 with the version number 10.0, 9.0 etc or go to the help and do a search for "javascript" and it should give you the appropriate page. Note that Pro stores have all the javascript variables, Manager stores have a subset and Starter level stores don't have them at all.
Perhaps you will need to add some javascript to the cart that will write that information to a file that you read with your application. You can add javascript to the shopping cart by going to Commerce Setup > Order System > Shopping cart and putting it in the field "Javascript added at start of built-in CheckIt function:" at the bottom of the screen.

ShopSite uses an SQlite database for the page, products etc. We do not offer support, advocate using or provide schema for the data in the database. There are some developers who have successfully used it to do various types projects. We cannot be held responsible if such use causes data corruption of the data or if we happen to change the schema and it breaks someones application that accesses the database. But that might be something that you could consider.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah


Return to User Forum

Who is online

Users browsing this forum: No registered users and 119 guests

cron