General Community > Scripting Help
SSI Authentication Issue
(1/1)
liability:
Hi everyone,
SMF 2.02
Using PHP on Apache server w/Linux shared host
I have a custom index page, in a different directory than my forum. I need to make sure the user is in certain group(s) before I show them any content.
No matter what I do though, I get my forums login page. I login, and I'm taken to my forums. I open a new tab, and try again - but it's the login page again. I hit my back button after logging in, and again, back to the login page. Nothing I do will authenticate me for the custom index page.
In admin > Configuration > Server Settings > Cookies and Sessions I have Use subdomain independent cookies enabled, along with Use database driven sessions.
In section 1, I have tried using the ssi_login() function (as the code shows) and without it. It makes no difference. (the ssi_login() form isn't displayed, and I always get the full login page)
I have tried using the $_SESSION['login_url'] function.
What the heck am I doing wrong here? It doesn't seem like it should be this difficult :(
--- Code: ---<?php
require ('../forums/SSI.php');
// Section 1: If they're not logged in, we'll tell them they need to
if ($context['user']['is_guest'])
{
echo"You need to login to the forums first";
ssi_login(); // with, or without this I get my forums full login page
}
else
{
// Section 2: If login is okay, and group matches we'll show them stuff
// Allowed groups is comma seperated SMF GROUP ID. Example: 1, 2, 3
$allowed_groups = array(10, 20, 24);
$can_see = FALSE;
foreach ($allowed_groups as $allowed)
if (in_array($allowed, $user_info['groups']))
{
$can_see = TRUE;
break;
}
if ($can_see)
{
Blah blah
}
// Section 3: This is what's displayed if they don't have the correct permissions (group)
else
{
echo"Sorry, your not allowed to see this.";
}
}
?>
--- End code ---
[Edit] My forum is on a sub domain (forums.mydomain.com) if that matters.
[Edit 2] Changed my forum url to the /forums/ address from the above, and login now works. But I still get the full login screen instead of the login form!
Navigation
[0] Message Index
Go to full version