News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

ssi_login(); issues

Started by Substance, December 25, 2009, 11:01:27 PM

Previous topic - Next topic

Substance

Hey SMF,

I seem to have issues with ssi_login();

Look here: http://www.monolithgaming.com, when I login it takes me to http://www.monolithgaming.com/forum which is incorrect. Also when I click the link back to my main page it logs me out? Session issue I think, any ideas?

Edit: Problem seems to be with linking back to the main site from the forum. Every time I click the very top link + Go to Main Site + it logs me out of SMF. Is there a way to link to the main site while keeping your session?

N3RVE

Can we see some code and a test account?

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

Substance

Absolutely:

http://www.monolithgaming.com/forum

Username: Test
Password: test

My main page index.php login / logout code

<?php
if($context['user']['is_guest']){
$_SESSION['login_url'] = 'http://www.monolithgaming.com/index.php';
ssi_login('http://www.monolithgaming.com');
}else{
$_SESSION['logout_url'] = 'http://www.monolithgaming.com/index.php';
echo '<div id="avatar">';
echo $context['user']['avatar']['image'];
echo '</div>
  <div id="uac_menu">
<p class="uacmenu"><a href="'
$scripturl'?action=profile">My Profile</a> +</p>
<p class="uacmenu"><a href="'
$scripturl'?action=profile">Settings</a> +</p>
<p class="uacmenu"><a href="'
$scripturl'?action=admin">AdminCP</a> +</p>
<p class="uacmenu"><a href="'
$scripturl'?action=logout;sesc='$sc'">'$txt[108], '</a></p>
   </div>
  <div id="uac_pm">'
;
echo $txt['hello_member'], ' <b>'$context['user']['name'], '</b>'allowedTo('pm_read') ? ', ' $txt[152] . ' <a href="' $scripturl '?action=pm">' $context['user']['messages'] . ' ' . ($context['user']['messages'] == '1' $txt[471] : $txt[153]) . '</a>' $txt['newmessages4'] . ' ' $context['user']['unread_messages'] . ' ' . ($context['user']['unread_messages'] == '1' $txt['newmessages0'] : $txt['newmessages1']) : '''.';
echo '</div>';
}
?>



SSI.php - function ssi_login();

function ssi_login($redirect_to = '', $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'], '">
<center>
<br /><b>Please login or register!</b><br /><br />
<input type="text" name="user" value="Username" size="20" maxlength="50" onfocus="if (value=\'Username\') {value=\'\'}" onblur="if (value==\'\') {value=\'Username\'}"/><br /><br />
<input type="password" name="passwrd" value="Password" size="20" maxlength="50" onfocus="if (value=\'Password\') {value=\'\'}" onblur="if (value==\'\') {value=\'Password\'}" /><br />
<input type="hidden" name="cookielength" value="-1" /><br />
<input type="submit" value="Login Now" /><br /><br />
<a href="', $scripturl, '?action=register">Click here to register!</a><br />
<a href="', $scripturl, '?action=reminder">Forgot your Password?</a>
</center>
</form>
';
}


Forum index.indextemplate.php (link from board to main page)

...
<div id="topnav"><p class="nav"><a href="http://www.monolithgaming.com">+ Go to Main Site +</a></p></div>
...


When I click that link ( "+ Go to Main Site +" ) on the forums index, it removes my session and logs me out... BUT if I manually go to the address bar, and just remove "/forum/..." from the link and hit enter, I go to the main site index.php and it keeps my session.


N3RVE

Sorry for the delay, it might be due to the edit in Index.template.php, mind attaching that file?

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

Substance


Substance

#5
Here n3rve, I've attached my theme. I based it off of orange-lt119v2 (credited in the settings file). I believe I changed up the "boardindex.template.php" since originally installing it. I've attached the one directly from my server.

Edit: Downloaded

N3RVE

Are you including SSI.php at the very first line after the opening tag in Index.php?

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

Substance

My main sites index.php is including it, yes.

N3RVE

I've looked though everything, made changes and tested on different setups and everything works as it should provided SSI.php is included at the very first line. I made all the changes in your post, including the modification to the ssi_login function and everything works, I retain the session, weird ::)

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

Substance

:( So nothing?

Do I have to include SSI.php in my forum index? I'd think not, but ya never know...

N3RVE

SSI.php only has to be included in your main site's Index.php file.

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

Arantor

Are local cookies enabled or disabled?
Holder of controversial views, all of which my own.


Substance

Quote from: Arantor on December 27, 2009, 08:36:14 AM
Are local cookies enabled or disabled?

Enable local storage of cookies is not checked.
Use subdomain independent cookies is not checked.

Arantor

Unless you have a strong reason not to, enable subdomain independent cookies.
Holder of controversial views, all of which my own.


Substance

That fixed it.

I'm an idiot, and you're a god among insects, thank you!  :)

Advertisement: