Concrete5 and Magento

Permalink
Good day, I have site based on concrete5 and shop(Catalog) based on Magento.
I want to show prices in Magento only for users which are logged in Concrete5.
I made static page with code:
<?php
            $uinfo = new User();
          if($uinfo->IsLoggedIn()){ 
             echo "1";
         } else { 
          echo "0";
       }
?>

It brings 1 i user is logged in. Basically it works, but when I try to import it via file_get_contents
it brings 0.
Can anyone help how to solve this issue?

lak17a
View Replies: View Best Answer
jaredquinn replied on at Permalink Best Answer Reply
jaredquinn
The isLoggedIn() function relies on checking some values in the current session.

So, you'll need to ensure that your session is maintained and more importantly, isn't clobbered by Magento's session management.

Concrete5 by default uses a session named 'CONCRETE5' unless it's over-ridden in your site.php file.

If you would like to check that there's a Concrete5 user logged in from within your Magento code, without loading the entire C5 framework, you could probably get away with doing something like (this hasn't been tested and is mostly off the top of my head):

$loginStatus = false;
session_write_close();
$o_sessionName = session_name();
$o_sessionID = session_id();
session_name('CONCRETE5');
if(isset($_COOKIE['CONCRETE5'])) {
  session_id($_COOKIE['CONCRETE5']);
} elseif(isset($_REQUEST['CONCRETE5'])) {
  session_id($_REQUEST['CONCRETE5']);
}
session_start();
if(isset($_SESSION['uID']) && $_SESSION['uID'] > 0 && isset($_SESSION['uName']) && $_SESSION['uName'] != '') {
   $loginStatus = true;
}
session_write_close();


Now testing the value of $loginStatus will tell you if there is a C5 user logged in or not. It won't be able to tell you anything more about them, but that seems to be all you want to know.

Jared
lak17a replied on at Permalink Reply
lak17a
Thanks, it worked ;)
DriveA320 replied on at Permalink Reply
I tried using your script, but it's always saying that a user is not logged in even if the user is logged in. What's the deal?
Arequal replied on at Permalink Reply
Arequal
manup replied on at Permalink Reply
manup
http://www.concrete5.org/community/forums/promotion/mage5-cms-solution-for-magento-store
manup replied on at Permalink Reply
manup
Mage5 is not yet popular yet, but you can try this Packagehttp://www.mage5.com/

See its Demo Video:http://youtu.be/pF4gJcZNrmE

I hope you are looking for this kind of solution ?