Arasius Posted June 8, 2016 Posted June 8, 2016 Hi Guys... Im trying to implement SSO,, but when I put this code: /* Require the init.php file from the Community Suite root directory */ require '/path/to/suite/init.php'; /* Initiate the session to verify who this user is */ \IPS\Session\Front::i(); /* Print the user's name */ print \IPS\Member::loggedIn()->name; In a external php file...I'm getting a number instead a name. A number like this: 40aa697366aa1ecd341992ab13fad20U3 yes I have changed init.php path.... Any clue?
Colonel_mortis Posted June 8, 2016 Posted June 8, 2016 If they are a guest, it will return the language string for guest rather than the member's name, and you need to pass it through \IPS\Member::loggedIn()->language()->parseOutputForDisplay( &$output ) to get "Guest".
Arasius Posted June 8, 2016 Author Posted June 8, 2016 Ty Mortis, But I need to show member display name. I'm the admin, it should show my admin name. how to? ty in advance
Colonel_mortis Posted June 8, 2016 Posted June 8, 2016 Where is the file located in terms of the web path? It's possible that the cookies aren't being sent to your script, because by default the cookie path for cookies set by the suite is just the suite itself, and they are also locked to HTTPS only if your base URL is HTTPS (so if your IPS installation is located at www.example.com/community/, the cookies aren't sent if you visit www.example.com/news/ or news.example.com, and they are also locked to HTTPS only if your base URL is HTTPS. There are instructions for changing the cookie settings at
Arasius Posted June 8, 2016 Author Posted June 8, 2016 my board: example.com/forum my php file: example.com/forum/directory/file.php
Colonel_mortis Posted June 8, 2016 Posted June 8, 2016 1 hour ago, Arasius said: my board: example.com/forum my php file: example.com/forum/directory/file.php And you're definitely logged in to the front, right? That code works for me, so I'm not sure why it wouldn't do for you.
Arasius Posted June 9, 2016 Author Posted June 9, 2016 Yes, I'm logged in.. Now I have changed my file to forum's root....and no success... Any idea?
Colonel_mortis Posted June 9, 2016 Posted June 9, 2016 21 minutes ago, Arasius said: Yes, I'm logged in.. Now I have changed my file to forum's root....and no success... Any idea? That's strange. If you add var_dump(\IPS\Request::i()->cookie); to the file, what is displayed?
Arasius Posted June 9, 2016 Author Posted June 9, 2016 This is the result: array(1) { ["IPSSessionFront"]=> string(32) "6dc98cde5cb389d09d3984c25cd83466" }
Colonel_mortis Posted June 9, 2016 Posted June 9, 2016 1 hour ago, Arasius said: This is the result: array(1) { ["IPSSessionFront"]=> string(32) "6dc98cde5cb389d09d3984c25cd83466" } If you're definitely logged into the site (front not ACP), which I presume you are, that's really weird. If the site is web accessible, you could post a link to the file, and I can have a look to try and figure out why the cookies aren't being sent. I just can't think of any reason that it wouldn't work, provided that it is being accessed over the same protocol (http/https) and domain, and it's within the suite's directory.
Arasius Posted June 9, 2016 Author Posted June 9, 2016 10 minutes ago, Colonel_mortis said: If you're definitely logged into the site (front not ACP), which I presume you are, that's really weird. If the site is web accessible, you could post a link to the file, and I can have a look to try and figure out why the cookies aren't being sent. I just can't think of any reason that it wouldn't work, provided that it is being accessed over the same protocol (http/https) and domain, and it's within the suite's directory. Sent you by pm. Ty !!!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.