T TufanM New member Jan 28, 2018 #1 I'm trying to build an external shop for my website, i need to get logged user's username on my PHP application but i have no idea how. How can i access to user data from PHP?
I'm trying to build an external shop for my website, i need to get logged user's username on my PHP application but i have no idea how. How can i access to user data from PHP?
Aayush Well-known member Jan 28, 2018 #2 Code: require ('/src/XF.php'); XF::start($dir); $app = XF::setupApp('XF\Pub\App'); $session = $app->session(); That should be able to get the XenForo Session. To access the visitor data, you can get that by Code: $visitor = \XF::visitor();
Code: require ('/src/XF.php'); XF::start($dir); $app = XF::setupApp('XF\Pub\App'); $session = $app->session(); That should be able to get the XenForo Session. To access the visitor data, you can get that by Code: $visitor = \XF::visitor();
T TufanM New member Jan 28, 2018 #3 Aayush said: Code: require ('/src/XF.php'); XF::start($dir); $app = XF::setupApp('XF\Pub\App'); $session = $app->session(); That should be able to get the XenForo Session. To access the visitor data, you can get that by Code: $visitor = \XF::visitor(); Click to expand... I am using the code below, it works. Is this the right implementation? Can someone fake their user ids by editing cookies etc.? PHP: require('src/XF.php'); \XF::start('/hc'); $app = \XF::setupApp('XF\Pub\App'); $s = $app->session(); $uid = $s->get('userId'); if ($uid){ $finder = \XF::finder('XF:User'); $user = $finder->where('user_id', $uid)->fetchOne(); print_r($user); }else{ echo 'guest'; }
Aayush said: Code: require ('/src/XF.php'); XF::start($dir); $app = XF::setupApp('XF\Pub\App'); $session = $app->session(); That should be able to get the XenForo Session. To access the visitor data, you can get that by Code: $visitor = \XF::visitor(); Click to expand... I am using the code below, it works. Is this the right implementation? Can someone fake their user ids by editing cookies etc.? PHP: require('src/XF.php'); \XF::start('/hc'); $app = \XF::setupApp('XF\Pub\App'); $s = $app->session(); $uid = $s->get('userId'); if ($uid){ $finder = \XF::finder('XF:User'); $user = $finder->where('user_id', $uid)->fetchOne(); print_r($user); }else{ echo 'guest'; }
Aayush Well-known member Jan 28, 2018 #4 These are sessions, not cookies. Sessions are hashed and set from the server. No one would be able to change it, unless they change the entire hash.
These are sessions, not cookies. Sessions are hashed and set from the server. No one would be able to change it, unless they change the entire hash.
T TufanM New member Jan 28, 2018 #5 Aayush said: These are sessions, not cookies. Sessions are hashed and set from the server. No one would be able to change it, unless they change the entire hash. Click to expand... Is there an api documentation for these methods? I couldn't find anything on google.
Aayush said: These are sessions, not cookies. Sessions are hashed and set from the server. No one would be able to change it, unless they change the entire hash. Click to expand... Is there an api documentation for these methods? I couldn't find anything on google.
Aayush Well-known member Jan 28, 2018 #6 TufanM said: Is there an api documentation for these methods? I couldn't find anything on google. Click to expand... For XenForo methods, we have Developer documentation. http://xenforo.com/dev-docs
TufanM said: Is there an api documentation for these methods? I couldn't find anything on google. Click to expand... For XenForo methods, we have Developer documentation. http://xenforo.com/dev-docs
T TufanM New member Jan 28, 2018 #7 Aayush said: For XenForo methods, we have Developer documentation. http://xenforo.com/dev-docs Click to expand... That link is gone
Aayush said: For XenForo methods, we have Developer documentation. http://xenforo.com/dev-docs Click to expand... That link is gone
T TufanM New member Jan 28, 2018 #9 ozzy47 said: It's here, https://xenforo.com/xf2-docs/dev/ Click to expand... I found that already, it doesn't seem to have all methods.
ozzy47 said: It's here, https://xenforo.com/xf2-docs/dev/ Click to expand... I found that already, it doesn't seem to have all methods.
Aayush Well-known member Jan 28, 2018 #10 Heres the updated link: https://xenforo.com/xf2-docs/dev/ There isn't a list of all the methods that you can use although you can simply import the XF code in an IDE and see all the methods that you can use come up as auto-suggestion.
Heres the updated link: https://xenforo.com/xf2-docs/dev/ There isn't a list of all the methods that you can use although you can simply import the XF code in an IDE and see all the methods that you can use come up as auto-suggestion.