Zen Cart Logo
Forums / General Questions / 1.5.4 Whoops! Your session has expired.

1.5.4 Whoops! Your session has expired.

Views: 2,883

Results 1 to 16 of 16
14 Jul 2015, 3:05 AM
#1
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

1.5.4 Whoops! Your session has expired.

I'm getting Whoops! Your session has expired. If I add something to the cart close the browser then come back to the website and try and add something to the cart again.

Is there a way to stop this from happening?

Server details:
Zencart 1.5.4
MySQL 5.6.24
5.6.8-1

14 Jul 2015, 1:00 PM
#2
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: 1.5.4 Whoops! Your session has expired.

I fixed the issue! Yesterday I enabled force cookie use under admin/session that was not the issue the last setting: Add period prefix to cookie domain
was not defined neither the true or false radio button was not selected, so of course I selected true since it says that is the default and that was the cause of my issue. I forgot I did that and after going crazy for a little while I remembered and changed it to false and no more Whoops! Your session has expired. error.

14 Jul 2015, 3:17 PM
#3
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: 1.5.4 Whoops! Your session has expired.

I do have a question, should I enable the force cookie use? I have it enabled now and does not seem to be effecting anything just want to make sure.

14 Jul 2015, 3:24 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: 1.5.4 Whoops! Your session has expired.

marcopolo:

I do have a question, should I enable the force cookie use? I have it enabled now and does not seem to be effecting anything just want to make sure.

Should use the default settings unless there is an issue that needs to be addressed by changing them... (Sorry doesn't directly answer the question of enable/not enable.)

17 Jul 2015, 12:12 PM
#5
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: 1.5.4 Whoops! Your session has expired.

I have similar problem.

In my case I am doing some customization on a local set, and getting the whoops only when I try the add to cart where I customized (messed up ;)), so it should be restricted to this:

I tried following [this thread www.zen-cart.com/showthread.php?43054-Add-Product-to-Cart-URL](https://www.zen-cart.com/showthread.php?43054-Add-Product-to-Cart-URL) and added the code in post #8

<form action="http://localhost/zencart_test/index.php?main_page=product_info&cPath=65/&products_id=180/&action=add_product" method="post" enctype="multipart/form-data" name="cart_quantity" id="cart_quantity">
<input type="hidden" name="cart_quantity" value="1" maxlength="6" size="4" />
<input type="hidden" name="products_id" value="180" />
<input name="image" type="image" title=" Add to Cart " src="includes/templates/template_default/buttons/english/button_in_cart.gif" alt="Add to Cart" />
</form>

What am I doing wrong?

Thank you.

p.s. adding trhu the normal procedure works fine.

17 Jul 2015, 12:16 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: 1.5.4 Whoops! Your session has expired.

Haven't included the sessionid into the form option. Assuming that the above is the html added in the product page, should use the ZC form generation function that would take care of that for you... As it is, the added code to the ZC process is designed to fail to prevent rogue cart operation.

17 Jul 2015, 3:07 PM
#8
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: 1.5.4 Whoops! Your session has expired.

Thank you mc12345678

I understand what you wrote, but don't know what how to do it!
I mean where do I put
void zen_draw_form( $name, $action, [ $method = 'post'], [ $parameters = ''])
and would I just added to the code in my earlier post?

Though I am sure you got what I am trying to do, please let me detail it more:

I have a slider where the image would link to the product page, and in the caption section I put the code to add the item to cart directly, and I just added the above code there.

17 Jul 2015, 4:31 PM
#9
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: 1.5.4 Whoops! Your session has expired.

keneso:

Thank you mc12345678

I understand what you wrote, but don't know what how to do it!
I mean where do I put
void zen_draw_form( $name, $action, [ $method = 'post'], [ $parameters = ''])
and would I just added to the code in my earlier post?

Though I am sure you got what I am trying to do, please let me detail it more:

I have a slider where the image would link to the product page, and in the caption section I put the code to add the item to cart directly, and I just added the above code there.

So if the above is something like this:

<?php //some amount of php
?><form action="http://localhost/zencart_test/index.php?main_page=product_info&cPath=65/&products_id=180/&action=add_product" method="post" enctype="multipart/form-data" name="cart_quantity" id="cart_quantity">
<input type="hidden" name="cart_quantity" value="1" maxlength="6" size="4" />
<input type="hidden" name="products_id" value="180" />
<input name="image" type="image" title=" Add to Cart " src="includes/templates/template_default/buttons/english/button_in_cart.gif" alt="Add to Cart" />
</form><?php // other php stuff 

Then would add the above like so:

<?php //some amount of php that ends at the end of this line;

zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($product_id), 'cPath=' . zen_get_generated_category_path_ids($product_id, 'product') . '&products_id=' . $product_id . '&action=add_product', $request_type), 'post', 'enctype=\"multipart/form-data\" id=\"cart_quantity\"');
?><input type="hidden" name="cart_quantity" value="1" maxlength="6" size="4" />
<input type="hidden" name="products_id" value="180" />
<input name="image" type="image" title=" Add to Cart " src="includes/templates/template_default/buttons/english/button_in_cart.gif" alt="Add to Cart" />
</form><?php // other php stuff 

Where $product_id is identified/set to the products_id of the product to which to link... There are other ways to present, but I figured if you have the product_id then the rest should fall in line with the above... Notice that the zen_draw_form is within the php code, not outside in the html code... Not exactly described above about how the html was being generated, so assumed that there is an opportunity to generate the html using php like above..

If instead you are going to hard code each of these links and not use the php type interface above, then need to include the code that is pushed at the end of the zen_draw_form function...

17 Jul 2015, 4:35 PM
#10
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

Re: 1.5.4 Whoops! Your session has expired.

mc12345678:

Php function from includes/functions/html_output.php with format as provided at: http://www.zen-cart.com/docs/phpdoc-1-5-0/functions/_includes---functions---html_output.php.html : zen_draw_form

void zen_draw_form( $name, $action, [ $method = 'post'], [ $parameters = ''])
It looks like that docs link needs an update, since the zen_draw_form function returns a string representing the form's <form> tag as well as the hidden input containing the securityToken value if the form's method is "post".

The OP can make the following change to include the securityToken value:

<form action="http://localhost/zencart_test/index.php?main_page=product_info&cPath=65/&products_id=180/&action=add_product" method="post" enctype="multipart/form-data" name="cart_quantity" id="cart_quantity">
<?php echo zen_draw_hidden_field ('securityToken', $_SESSION['securityToken']); ?>
<input type="hidden" name="cart_quantity" value="1" maxlength="6" size="4" />
<input type="hidden" name="products_id" value="180" />
<input name="image" type="image" title=" Add to Cart " src="includes/templates/template_default/buttons/english/button_in_cart.gif" alt="Add to Cart" />
</form>
17 Jul 2015, 4:41 PM
#11
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: 1.5.4 Whoops! Your session has expired.

Yup, which means that before the use of zen_draw_form will need to add

 echo 

So that it looks like:

<?php //some amount of php that ends at the end of this line;

echo zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($product_id), 'cPath=' . zen_get_generated_category_path_ids($product_id, 'product') . '&products_id=' . $product_id . '&action=add_product', $request_type), 'post', 'enctype=\"multipart/form-data\" id=\"cart_quantity\"');
?><input type="hidden" name="cart_quantity" value="1" maxlength="6" size="4" />
<input type="hidden" name="products_id" value="180" />
<input name="image" type="image" title=" Add to Cart " src="includes/templates/template_default/buttons/english/button_in_cart.gif" alt="Add to Cart" />
</form><?php // other php stuff 
17 Jul 2015, 6:47 PM
#12
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: 1.5.4 Whoops! Your session has expired.

Thank you both.

@ mc12345678

If ever possible you got me more confused ;)

Sorry for not having been very clear, I am hard coding the links (only half a dozen items), although I would guess your suggestion would be much better, and flexible ... if I only knew ...

I ended up using lat9's suggestion which works just fine in my setup.

For your info the template file I am using is basically html, the only php is for the language definitions here is the code.
I have put the slider code in a file which I include in the template file I need.
Of course the <div class="item"> is repeated as many times as the products in the slider.

<div class="slider-wrapper">
	<div class="item active">
		<div class="col-xs-12 col-md-9">
			<img src="<?php  echo $template->get_template_dir('',DIR_WS_TEMPLATE, $current_page_base,'images/carousel').'/'.IMAGE_01 ?>" alt="" />
		</div>
		<div class="carousel-caption col-xs-12 col-md-3">
			<h3><?php echo IMAGE_01_TITLE ?></h3>
			<div class="fz-product-info-box">
			<?php echo IMAGE_01_INFO ?>
				<form action="http://localhost/zencart_test/index.php?main_page=product_info&cPath=65/&products_id=180/&action=add_product" method="post" enctype="multipart/form-data" name="cart_quantity" id="cart_quantity">
				<?php echo zen_draw_hidden_field ('securityToken', $_SESSION['securityToken']); ?>
				<input type="hidden" name="cart_quantity" value="1" maxlength="6" size="4" />
				<input type="hidden" name="products_id" value="180" />
				<input name="image" type="image" title=" Add to Cart " src="includes/templates/template_default/buttons/english/button_in_cart.gif" alt="Add to Cart" />
				</form>
			</div>
		</div>
	</div>
</div>
17 Jul 2015, 7:02 PM
#13
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: 1.5.4 Whoops! Your session has expired.

No problem... For hard coding the session information was the only thing that was missing and as lat9 provided was easily provided/added.. I thought that you had a more dynamic situation going on which was why I provided the "plug-and-play" version to build the URI link...

Same end result, a successful method of adding a product to the cart, hopefully a happy customer(s) and more sales. :)

If I may offer a suggestion that should make transferring this to a live/other site a little easier.

Change: ```
<form action="http://localhost/zencart_test/index.php?main_page=product_info&cPath=65/&products_id=180/&action=add_product" method="post" enctype="multipart/form-data" name="cart_quantity" id="cart_quantity">

to:

<form action="<?php echo ($request_type == 'SSL' ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG); ?>index.php?main_page=product_info&cPath=65/&products_id=180/&action=add_product" method="post" enctype="multipart/form-data" name="cart_quantity" id="cart_quantity">



Trying to write too quickly... Keep making mistakes...
19 Jul 2015, 9:55 AM
#14
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: 1.5.4 Whoops! Your session has expired.

Thank you.

mc12345678:

No problem... For hard coding the session information was the only thing that was missing and as lat9 provided was easily provided/added.. I thought that you had a more dynamic situation going on which was why I provided the "plug-and-play" version to build the URI link...

Yes, kinda figured you thought of a more dynamic (complex to me) situation, and my post was as a FYI.

mc12345678:

If I may offer a suggestion that should make transferring this to a live/other site a little easier.

All suggestions are more than welcomed, specially from more knowledgeable people; thanks again.

19 Jul 2015, 1:57 PM
#15
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: 1.5.4 Whoops! Your session has expired.

I just can't seem to leave it alone. I just realized that the paragraph after the last offering of code is no longer accurate. The provided code will fill in the information necessary to get to the directory where the index.php for the store's cart is located using the current method of loading the current page (https: or http:).

When I first wrote the change (those subscribed to the thread saw this) I was using the hard coded subdirectory in the path and then realized I hadn't just simply put it all together to use the database infromation associated with the path to get to the index.php file.

Anyways, this way although transferring the new added code to a site with a different product/category setup than your local version (which hopefully is a duplicate of some live version) would need some tweaking, the more independent of the current store yet fully functional, the easier it is to use the code elsewhere with potentially less maintenance/modification.

Anyways, poorly trying to correct the mistake in my last post as the last paragraph doesn't exactly apply with the way that the code was rewritten... Guess will find out how confused someone else is/will be when they revive the thread in the future. :P

20 Jul 2015, 12:10 PM
#16
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: 1.5.4 Whoops! Your session has expired.

mc12345678:

I just can't seem to leave it alone.
<on the Beatles Let It Be tune>
Let it go, let it go ;)

mc12345678:

Guess will find out how confused someone else is/will be when they revive the thread in the future. :P
If any way close to me, some will be ... but that doesn't have to do with your code ;)