News:

Wondering if this will always be free?  See why free is better.

Main Menu

Help needed with SSI login

Started by barry1947, October 18, 2017, 11:54:41 AM

Previous topic - Next topic

barry1947

Hi everyone,
I seem to have problems with getting login information via SSI. most of the time it works fine. Sometimes when clearly logged into the forum as Administrator, the script refuses to recognize the login and it will issue the message "You Must Login To The Forum First". I am running version 2.0.14 I have cleared the browser cache in chrome.
Does anyone have any ideas with this. It is just a single page of code that starts with the following.

<?php
require_once('../SSI.php');
global $context;
if (!$context['user']['is_logged']) {
   die("You Must Login To The Forum First");
}

Many thanks
Barry

Arantor

It's a bug in 2.0.14 that should be fixed in 2.0.15.

Change ssi_login in SSI.php to look like this:


// Shows a login box.
function ssi_login($redirect_to = '', $output_method = 'echo')
{
global $scripturl, $txt, $user_info, $context, $modSettings;

if ($redirect_to != '')
$_SESSION['login_url'] = $redirect_to;

if ($output_method != 'echo' || !$user_info['is_guest'])
return $user_info['is_guest'];

echo '
<form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '">
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td align="right"><label for="user">', $txt['username'], ':</label>&nbsp;</td>
<td><input type="text" id="user" name="user" size="9" value="', $user_info['username'], '" class="input_text" /></td>
</tr><tr>
<td align="right"><label for="passwrd">', $txt['password'], ':</label>&nbsp;</td>
<td><input type="password" name="passwrd" id="passwrd" size="9" class="input_password" /></td>
</tr>';

// Open ID?
if (!empty($modSettings['enableOpenID']))
echo '<tr>
<td colspan="2" align="center"><strong>&mdash;', $txt['or'], '&mdash;</strong></td>
</tr><tr>
<td align="right"><label for="openid_url">', $txt['openid'], ':</label>&nbsp;</td>
<td><input type="text" name="openid_identifier" id="openid_url" class="input_text openid_login" size="17" /></td>
</tr>';

echo '<tr>
<td><input type="hidden" name="cookielength" value="-1" /></td>
<td><input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /><input type="submit" value="', $txt['login'], '" class="button_submit" /></td>
</tr>
</table>
</form>';

}

barry1947

Many Thanks Arantor,
So far it is looking good.
Have a great week and best regards from me.
Barry

Elyra

I had the same problem using exactly this code at the beginning of my own pages.

For me the problem was the hostname.
I logged into the forum using
https:// www. example. com/

but for my own page i used
https:// example. com/myPage.php

and it did not recognize i was logged in.
As soon as i switched to
https:// www. example. com/myPage.php

everything worked fine.
Maybe you could check that, if it keeps happening for you.

Kind regards
Elyra

Arantor

Your problem is that you didn't configure subdomain independent cookies in the admin area before using it across subdomains (cookies on example.com aren't the same by default as cookies on www.example.com)

I'd note that the OP's issue is definitely a 2.0.14 bug that will be fixed in 2.0.15.

Elyra

Thanks, i will take a look at the subdomain settings for cookies, i just thought i share this because the symptoms of my problems were the same  :)

Arantor

There were a bunch of problems in the 2.0.14 release relating to this :(

Advertisement: