Page 1 of 1

Display OC name on external page?

Posted: Thu Feb 17, 2011 3:24 am
by RJonesUSC
Hi, I'm new to OC only having used it for about a week now. I have a situation where I need to access user account session data on an external/non-OC page. I've done this in the past with other db apps such as phpbb and the like but I can't seem to find out how to do it with OC.

Can anyone point me in the right direction to get this done? I really just need the user_id to then query it and display info based on the user's customer group.

Thanks in advance

Re: Display OC name on external page?

Posted: Fri Feb 18, 2011 4:52 am
by justinv
Are the two sites on the same domain? If so you could write the userid into a cookie and read it that way on the other site.

Re: Display OC name on external page?

Posted: Fri Feb 18, 2011 5:19 am
by RJonesUSC
Thanks for the suggestion. When setting the cookie, what variable do I use for the OC userid? In PHP, how do I call the userid, username, etc. of who's logged in? That user session handling info is what I'm after.

Re: Display OC name on external page?

Posted: Fri Feb 18, 2011 5:27 am
by Qphoria
$this->customer->getFirstName();
$this->customer->getLastName();
$this->customer->getEmail();

Re: Display OC name on external page?

Posted: Fri Feb 18, 2011 5:31 am
by RJonesUSC
Qphoria wrote:$this->customer->getFirstName();
$this->customer->getLastName();
$this->customer->getEmail();
Thanks. If I run that on a page outside of OC (say on a plan 'ol php page located at the root of the OC install) do you happen to know what includes are needed to use that class and functions?

Re: Display OC name on external page?

Posted: Fri Feb 18, 2011 8:32 am
by justinv
It's not going to be simple, you'd need a hybrid of the customer class, you'd need a db connection to the OC db. The easiest way is to make the call to $this->customer->getXXXXX() and write it to a cookie. Then your other application can read it straight from the cookie.