Zen Cart Logo
Forums / Code Collaboration / Whoops! Your session has expired. when adding to cart from external link

Whoops! Your session has expired. when adding to cart from external link

Views: 3,605

Results 1 to 4 of 4
8 Jun 2015, 3:32 PM
#1
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Whoops! Your session has expired. when adding to cart from external link

Hey all, I have a customer that uses a different landing page for some special needs clients, I am using this code on the external page:

<form name="cart_quantity" action="https://mysite.net/index.php?main_page=product_info&action=add_product" method="post" enctype="multipart/form-data">
    <input type="hidden" name="cart_quantity" value="1" />
    <input type="hidden" name="products_id" value="'.$theProductId.'" />
    <input type="submit" value=" ADD TO CART " /><br />
</form>

But when click, takes me to the shopping cart page, but displays the:
Whoops! Your session has expired.

I have read several posts and nothing is working for me, I also saw a post from Dr Byte talking about a change in ZC 1.5, is there a work around? can i do this?
Thanks in advance
Jeff

8 Jun 2015, 5:00 PM
#2
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Whoops! Your session has expired. when adding to cart from external link

Be aware "cross-site requests" will be blocked for obvious security reasons. Your "different landing page" will need to reside on the same server / domain (and can then be proxied if needed - or - the multisite modification utilized if branding is required).

The easiest solution is converting the external "different landing page" to an internal Zen Cart page. This way the "different landing page" has access to Zen Cart's session, functions, and security framework.

NOTE: The above is based on the very limited information provided by the original poster. If more detailed information is provided, additional solutions may present themselves. In order to provide anything beyond an educated guess, the volunteers on these forums need the original poster to provide: answers to the questions in the "posting tips", URLs to both the landing page and the Zen Cart site, and detailed information regarding the desired end result.

8 Jun 2015, 5:34 PM
#3
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Re: Whoops! Your session has expired. when adding to cart from external link

Thank you for the quick response, it is on the same domain, is it possible to use application top outside of the includes dir? when i tired to do that i got a wite page and decided not to peruse it because i though it may have issue.
Can you use application top outside of includes?

8 Jun 2015, 8:08 PM
#4
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Whoops! Your session has expired. when adding to cart from external link

I would not recommend doing so. Instead take a look at how Zen Cart pages are constructed.

For example the Zen Cart "contact_us" page:
"/includes/modules/pages/contact_us/header.php" - Business rules and DB queries.
"/includes/languages/<your langauge>/contact_us.php" - Langauge constants (for your language).
"/includes/templates/<your template>/templates/tpl_contact_us_default.php" - The HTML template used.

So if you wanted to create your own page "my_special_landing":
"/includes/modules/pages/my_special_landing/header.php" - Business rules and DB queries.
"/includes/languages/<your langauge>/my_special_landing.php" - Langauge constants (for your language).
"/includes/templates/<your template>/templates/tpl_my_special_landing_default.php" - The HTML template used.
"/includes/extra_datafiles/my_special_landing.php" - add a FILENAME constant:

<?php
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}

define('FILENAME_MY_SPECIAL_LANDING', 'my_special_landing');

And then the page can be accessed via with a web browser at "/index.php?main_page=my_special_landing". On any internal Zen Cart page you can create a link to this page using "zen_href_link(FILENAME_MY_SPECIAL_LANDING);".

You then will want to take a look at how the products_info page works (as it contains a form to "buy now" a specific product_id). You will probably need to adjust the DB queries and HTML some, but should hopefully give a viable example...