Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: cbearhoney on April 30, 2009, 03:14:50 PM

Title: Problem with ssi_login redirect...HELP!
Post by: cbearhoney on April 30, 2009, 03:14:50 PM
Has anyone seen this problem? I'm using ssi_login('myurl') to log in members into SMF and redirect to 'myurl'. This works, but when the member goes back to SMF index.php, it looks as if the member isn't logged in. Only after clicking on a topic or post does the member name show up.  How do I force SMF index to recognize the logged in member?  thanks for the help.

login.php

<?php
require("header.php");
require(
"../smf/SSI.php");
?>
<h1>Sign In using SMF </h1>

<?php

ssi_login
('http://www.myurl.com');

require(
"footer.php");
?>


SSI.php

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

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[35], ':</label>&nbsp;</td>
<td><input type="text" id="user" name="user" size="9" value="', $user_info['username'], '" /></td>
</tr><tr>
<td align="right"><label for="passwrd">', $txt[36], ':</label>&nbsp;</td>
<td><input type="password" name="passwrd" id="passwrd" size="9" /></td>
</tr><tr>
<td><input type="hidden" name="cookielength" value="-1" /></td>
<td><input type="submit" value="', $txt[34], '" /></td>
</tr>
</table>
</form>';
}