Create A Login Page When First Loaded Website

Hi All,



I plan to create a login page when first opened website (like admin login page), only registered customers can view my website (storefront). I’ve managed to connect to the database and retrieve user data. The problem is in session, I do not know how to set a session when a successful login. I tried setting $ _SESSION [‘auth’] variable, but cannot. Please help.

If $_SESSION['auth']['user_id'] is not empty, it means that the user is logged in



Hope that helps.

Thank you for your informastion, i tried but still cannot.

I modify the index.php page, such as the following:



[size=3]if(!empty($_SESSION['auth']['user_id'])) {

$php_value = phpversion();

if (version_compare($php_value, '5.3.0') == -1) {

echo 'Currently installed PHP version (' . $php_value . ') is not supported. Minimal required PHP version is 5.3.0.';

die();

}



define('AREA', 'C');

require dirname(FILE) . '/init.php';



fn_dispatch();



}[/size]




My logic is make a login form on index.php page, if login successful, I did set the $_SESSION['auth'].

Are there any other better way?

We can offer you to try our new free Login Redirect module which is available through the following link:



"Login Redirect" Add-on for CS-Cart and Multi-Vendor



If you have any questions, please let me know.

You should use a hook for 'fill_auth'. The logic would be something like


if( empty($_SESSION['auth']['user_id']) ) && Registry::get('runtime.controller') != 'auth' && AREA == 'C')
fn_redirect("auth.login_form');




So this would equate to

User comes to customer site and is not logged in

redirect them to the 'auth' controller with mode 'login_form'



If Ecomm's addon does it for you, then it's certainly always better to use a commercial and supported piece of code. But it doesn't appear that their module does what you're looking for.

Give this free addon a try. Note that this will prevent robots from crawling your site too…

http://ez-ms.com/pri…_login_v4.2.tgz



P.S. It allows you to enable it on a store by store basis in multi-store environments. So x.site.com could require a login and y.site.com would not.

[quote name='tbirnseth' timestamp='1408479936' post='189995']

If Ecomm's addon does it for you, then it's certainly always better to use a commercial and supported piece of code. But it doesn't appear that their module does what you're looking for.

[/quote]



Why do you think so? Our module shows Sign in page for the unlogged customers. More other it allows to specify a page to which the customer will be redirected after he logs in. For example, you can use promotion page instead of the home page.


[quote name='tbirnseth' timestamp='1408510329' post='190026']

Give this free addon a try. Note that this will prevent robots from crawling your site too…

http://ez-ms.com/pri…_login_v4.2.tgz



P.S. It allows you to enable it on a store by store basis in multi-store environments. So x.site.com could require a login and y.site.com would not.

[/quote]



Thank you. We have checked the code. Note that your module kills callbacks from the payment systems.

When I read the description on your site I had thought it indicated that it was setup for specific products/pages. Re-reading, it does in fact indicate that un-logged-in users can be redirected. So either it's been rewritten or I miss-read.



I've excluded payment_notifications controller as well as profiles and auth controllers from the 5 lines of code that were written to address this.



I would recommend that merchants use ecomm's addon since it has more functionality and is also free. I didn't intend to try to undercut another developer. Was just trying to get the merchant's problem addressed. I'll remove remove reference to the code I put together.

[quote name='eComLabs' timestamp='1408453696' post='189949']

We can offer you to try our new free Login Redirect module which is available through the following link:



http://www.ecom-labs…ect-add-on.html



If you have any questions, please let me know.

[/quote]





Thank you for free add on, enough to help me but it did not suit my needs. My plan is to create their own login page to enter the storefront page (such as admin login page). Is such a thing allowed to be done in CS Cart? I am new to CS Cart, please help.

[quote name='Andry MIS' timestamp='1408586172' post='190131']

Thank you for free add on, enough to help me but it did not suit my needs. My plan is to create their own login page to enter the storefront page (such as admin login page). Is such a thing allowed to be done in CS Cart? I am new to CS Cart, please help.

[/quote]



I wanted the same feature that you are looking for, since I run a distributor website. I only sell to specific stores, hence why I need a login to view and buy my products. I didn't get it from eCom labs, but I paid $45 for it and it works great. But honestly, I don't want to remove a sale from eCom, so I would go with him/her since they were the first to try to help you. Plus from what I can see on their website, it's exactly the same thing I have, plus they let you name your price it looks like. It's an small investment that's worth it.

[quote name='SwimShady' timestamp='1408588184' post='190133'] I wanted the same feature that you are looking for, since I run a distributor website. I only sell to specific stores, hence why I need a login to view and buy my products. I didn't get it from eCom labs, but I paid $45 for it and it works great. But honestly, I don't want to remove a sale from eCom, so I would go with him/her since they were the first to try to help you. Plus from what I can see on their website, it's exactly the same thing I have, plus they let you name your price it looks like. It's an small investment that's worth it. [/quote]



Thank you for the kind words. BTW, please check the new version of the module



[DELETED]



Note: the installation package is not updated on our website yet

We have updated the installation package. The Disable account registration setting was added. If this setting is enabled, the own Sign in page to enter the storefront page will be displayed.







In other case the customer will see default Sign in page with the ability to register new account

This addon must to be included in to default Cscart :)

Thanks for addon

[quote name=‘becomarius’ timestamp=‘1409305759’ post=‘191025’]

This addon must to be included in to default Cscart :)

Thanks for addon

[/quote]





You are welcome!

We have updated the installation package. The [b]Disable account registration[/b] setting was added. If this setting is enabled, the own [b]Sign in[/b] page to enter the storefront page will be displayed.



In other case the customer will see default [b]Sign in[/b] page with the ability to register new account

Hi,

i installed your addon and its works fine.

i am wondering that is it possible to redirect unlogged customer to "login PopUp" not to login page.

the same login pop that open when we click on singin Under My account link.

Is that possible ?

Please help me

This addon must to be included in to default Cscart smile.png
Thanks for addon