Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / How do I redirect a user from landing page to my index if they're already logged in?

How do I redirect a user from landing page to my index if they're already logged in?

22 Jul 2011, 1:05 AM
#1
adalovelace avatar

adalovelace

New Zenner

Join Date:
Mar 2011
Posts:
27
Plugin Contributions:
0

Post #1 by adalovelace

How do I redirect a user to my main website index page (main_page=index) if she/he is already logged in? (This is the default behavior when one goes to http://www.continentalbeadsuppliers.com.) I'd just like to know the code that makes this possible. :smile:


The reason I want to do this is because we run a website that requires a user to log in first.

Due to a restriction in Google AdWords' terms, I had to create a new log in page. (They do not allow the landing page to contain "data collection" i.e. new user signup fields.)

So I created a page for new user sign up, and I included an existing user login option as well (because omitting this confused the hell out of my users when they inadvertently stumbled upon the new user page). The problem is that if a user is ALREADY logged in, she/he is prompted to log in again.

And help is GREATLY appreciated! :smile:

22 Jul 2011, 5:14 AM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Post #2 by rodg

AdaLovelace:

How do I redirect a user to my main website index page (main_page=index) if she/he is already logged in?

This is a head spinner. If a customer is already logged in you really don't wnat to be redirecting them anywhere.

AdaLovelace:

(This is the default behavior when one goes to http://www.continentalbeadsuppliers.com.) I'd just like to know the code that makes this possible. :smile:

The default page for this site is the login page, quite the opposite to what you appear to be asking for.

AdaLovelace:

The reason I want to do this is because we run a website that requires a user to log in first.

Ergo, you DO want the same as the site above, which does take you to the login page first.

AdaLovelace:

Due to a restriction in Google AdWords' terms, I had to create a new log in page. (They do not allow the landing page to contain "data collection" i.e. new user signup fields.)

And here you are saying you DON'T want the default page to be the login page.

Which is it? Am I the only one confused about what you actually want/need?

AdaLovelace:

Any help is GREATLY appreciated! :smile:

I think what you may looking for is the setting found under
/configuration/layout_settings/
"Main Page - Opens with Category"

By setting this option, your default landing page will be for the category that you set, rather than whatever the default page normally is.

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

22 Jul 2011, 9:05 PM
#3
adalovelace avatar

adalovelace

New Zenner

Join Date:
Mar 2011
Posts:
27
Plugin Contributions:
0

Post #3 by adalovelace

I'm sorry. I know this is confusing. I think the key is that since our website is password protected, NOTHING is visible to anyone unless they are logged in.

If they are not logged in, whenever they click on ANY page, it always takes them to the login page (main_page=login). If they ARE logged in, they are directed to our main page (main_page=index).

In short, what I would like is for when a user goes to main_page=preview, I would like them to be directed to main_page=index if they are logged in. :)

22 Jul 2011, 9:14 PM
#4
drbyte avatar

drbyte

Sensei

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

Post #4 by drbyte

In your header_php.php file for your preview page, check whether $_SESSION['customer_id'] is set and is non-zero, and in such cases do a zen_redirect. You'll see similar checks for "not logged in" status in the checkout_shipping page, for example.

.
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.

22 Jul 2011, 9:27 PM
#5
adalovelace avatar

adalovelace

New Zenner

Join Date:
Mar 2011
Posts:
27
Plugin Contributions:
0

Post #5 by adalovelace

THANK YOU!! That is exactly what I wanted to know. :) <333