Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to require login


jtingle

Recommended Posts

First, I love OsCommerce

 

I have been looking at code till my eyes hurt. :D

 

Is there a way to require login on a page that I have created.

 

I know there is and I have been looking for a require statement, am I off base :?:

 

Any help will be greatly appreciated.

Link to comment
Share on other sites

Edit the /includes/application_top.php and change the line:

// Shopping cart actions

 

To read:

// WebMakers.com Added: Forced Login

 if (!tep_session_is_registered('customer_id') and (!strstr($PHP_SELF,FILENAME_LOGIN) and !strstr($PHP_SELF,'create'))) {

   $navigation->set_snapshot();

   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

 }



// Shopping cart actions

 

It is important that the word 'create' be used rather than the filename otherwise you need to define all of the create_ files individually to process new accounts as well as login an existing account.

Link to comment
Share on other sites

Thanks Linda

 

nice 'TIP' about 'create'

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

Got to watch for those background file processes that happen when a submit occures and be sure to include them if they are about to pass through a redirect statement that also is dependant on filename.

 

Otherwise ... you wonder what that white page is ... 8)

 

And that is the perpetual loop until the server craps out your php routine ... providing it does terminate it for you eventually. :oha:

Link to comment
Share on other sites

sure...

 

looking in the top of checkout_shipping.php provides this code:

 

// if the customer is not logged on, redirect them to the login page

 if (!tep_session_is_registered('customer_id')) {

   $navigation->set_snapshot();

   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

 }

 

this is placed at the beginning of all pages in OSC that require login.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

Let's say you want the customer logged in to go to the privacy.php page.

 

Adding this after the application_top.php and language file is loaded would send the customer to login if not already logged in.

// WebMakers.com Added: Forced Login Per Page

 if (!tep_session_is_registered('customer_id')) {

   $navigation->set_snapshot();

   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

 }

Link to comment
Share on other sites

  • 1 month later...

What about when someone clicks on Forgot password? The page won't go anywhere, but stays on the Login Page...

 

 

Edit the /includes/application_top.php and change the line:

// Shopping cart actions

 

To read:

// WebMakers.com Added: Forced Login

 if (!tep_session_is_registered('customer_id') and (!strstr($PHP_SELF,FILENAME_LOGIN) and !strstr($PHP_SELF,'create'))) {

   $navigation->set_snapshot();

   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

 }



// Shopping cart actions

 

It is important that the word 'create' be used rather than the filename otherwise you need to define all of the create_ files individually to process new accounts as well as login an existing account.

Link to comment
Share on other sites

  • 3 months later...
  • 6 years later...

This tip works great, but the forgotten password page does not work. I know you said to just add the pages to the if statement, but can you please be a little more specific?

 

Thanks for your help.

 

Tyler Watkins

Myrtle Beach, SC

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...