Site maintenance: Sun 15 Nov, from 12:00 UTC, about 4–6 hours. Details

This cutover relies on some testing that is still incomplete so may be cancelled at short notice

Forums / General Questions / Navigation snapshot code broken?

Navigation snapshot code broken?

Locked

Started by alex_clarke on 23 Feb 2010, 11:47 AM · Views: 2,063

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
23 Feb 2010, 11:47 AM
#1
alex_clarke avatar

alex_clarke

Totally Zenned

Join Date:
Mar 2006
Posts:
909
Plugin Contributions:
1

Navigation snapshot code broken?

I've been looking into why I'm always redirected to my website's home page after I login. On most ecommerce websites I expect to be directed back to the previous page.

Can someone please explain what the following code in includes/modules/pages/login/header_php.php does?

        if (sizeof($_SESSION['navigation']->snapshot) > 0) {
          //    $back = sizeof($_SESSION['navigation']->path)-2;
          //if (isset($_SESSION['navigation']->path[$back]['page'])) {
          //    if (sizeof($_SESSION['navigation']->path)-2 > 0) {
          $origin_href = zen_href_link($_SESSION['navigation']->snapshot['page'], zen_array_to_string($_SESSION['navigation']->snapshot['get'], array(zen_session_name())), $_SESSION['navigation']->snapshot['mode']);
          //            $origin_href = zen_back_link_only(true);
          $_SESSION['navigation']->clear_snapshot();
          zen_redirect($origin_href);
        } else {
          zen_redirect(zen_href_link(FILENAME_DEFAULT, '', $request_type));
        }

To me, it looks like it sends the visitor to their last page (before logging in). However, I always end up on the home page.

Is this code broken?

All the best,

Alex

My Contributions: Zen Lightbox | Best Sellers Reloaded

23 Feb 2010, 2:12 PM
#2
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: Navigation snapshot code broken?

I have used this and it seemed to work.

Fix back history to previous page modules/pages/login/header_php.php
org code:
} else {
    zen_redirect(zen_href_link(FILENAME_DEFAULT));
}
replace with:
} else {
    $origin_href = zen_back_link_only(true);
    zen_redirect($origin_href);
}

Skip

• 446F63746F722057686F •

23 Feb 2010, 2:19 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Navigation snapshot code broken?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

23 Feb 2010, 2:53 PM
#4
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: Navigation snapshot code broken?

Sorry missed that update.

Skip

• 446F63746F722057686F •

23 Feb 2010, 7:42 PM
#5
alex_clarke avatar

alex_clarke

Totally Zenned

Join Date:
Mar 2006
Posts:
909
Plugin Contributions:
1

Re: Navigation snapshot code broken?

DrByte:

http://www.zen-cart.com/forum/showpost.php?p=547637&postcount=20

I'm currently using this code and experience the following issue.

If I am on a product_info page and then login I will be returned to that same product_info page - which is correct.

However, If I'm on the shopping_cart page and login I will be returned to the home page - which is incorrect (as I should be redirected back to the shopping_cart page.

Does anyone else experience this?

Regards,

Alex

My Contributions: Zen Lightbox | Best Sellers Reloaded

23 Feb 2010, 10:04 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Navigation snapshot code broken?

That's normal, as there is no snapshot taken on the shopping cart page. Snapshots are only taken on pages that require login. However, if you click the "Go to Checkout" button, a snapshot will be taken if the customer isn't logged in yet, then they will be taken to the login page, and then returned to checkout normally.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

24 Feb 2010, 10:32 AM
#7
alex_clarke avatar

alex_clarke

Totally Zenned

Join Date:
Mar 2006
Posts:
909
Plugin Contributions:
1

Re: Navigation snapshot code broken?

Thanks for explaining this.

Is it possible to take snapshots on all pages (to ensure that the customer is returned to their previous page after login)?

I'm currently using sessions to achieve the above. If I could simply modify the snapshot code that already exists that would obviously be much better.

All the best,

Alex

My Contributions: Zen Lightbox | Best Sellers Reloaded

24 Feb 2010, 10:35 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Navigation snapshot code broken?

See Similar Threads below for ideas.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

24 Feb 2010, 2:20 PM
#9
alex_clarke avatar

alex_clarke

Totally Zenned

Join Date:
Mar 2006
Posts:
909
Plugin Contributions:
1

Re: Navigation snapshot code broken?

Thanks DyByte.

I've currently written some code that I'm using (just on the login page) to work around this. All appears to be working well... so I'll stick with it for now.

Regards,

Alex

My Contributions: Zen Lightbox | Best Sellers Reloaded