News:

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

Main Menu

Redirecting after using the ssi_login () and ssi_logout()

Started by tectonny, August 28, 2015, 02:29:01 PM

Previous topic - Next topic

tectonny

This code no longer works.

<?php
if ($user_info['is_guest'])
{
 
$_SESSION['login_url'] = 'http://mysite.com/index.php';
 ssi_login(); ?>
<br />
     <?php
}
else
{

 
$_SESSION['logout_url'] = 'http://mysite.com/index.php';
ssi_logout(); 

?>

Oldiesmann

You can just specify the URL to redirect them to as a function parameter now...

ssi_login('http://www.mysite.com/index.php');

Same with ssi_logout.
Michael Eshom
Christian Metal Fans

tectonny

Thanks for the quick response.

I did so it did not work, see my code.
<?php

$shoutbox_id 
4;
$ssi_layers = array('html');

require(
'SSI.php');

if (
$context['user']['is_guest']) {
echo '<div id="loggedOutDiv">';
ssi_login('http://www.tectonny.com.br/forum/chat.php');
echo '</div>';
}
else {
echo 
<div id="loggedIn">
Bem Vindo, ' 
$context['user']['name'] . '
<br />
'
;
ssi_logout('http://www.tectonny.com.br/forum/chat.php');
echo '
</div>
'
;
}


echo 
'
<div class="windowbg" style="padding: 1em; overflow: auto; margin: 1em;">
'
sp_shoutbox(array('shoutbox' => $shoutbox_id), 0), '
</div>'
;


?>


Test:
http://www.tectonny.com.br/forum/chat.php

Oldiesmann

Looking into this further, it appears the functionality was completely broken at some point.

// Set the login URL - will be used when the login process is done (but careful not to send us to an attachment).
if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
$_SESSION['login_url'] = $_SESSION['old_url'];
else
unset($_SESSION['login_url']);


If $_SESSION['old_url'] is set, isn't pointing to an attachment and is pointing to a board or topic, you get redirected. Otherwise we simply ignore $_SESSION['login_url'] entirely. I'm not sure why this was done but will look into it further.
Michael Eshom
Christian Metal Fans


Oldiesmann

I know. The above code is from the login function, where we essentially ignore $_SESSION['login_url'].

This should fix the issue though (note this hasn't been tested).

Sources/LogInOut.php

Find
if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
$_SESSION['login_url'] = $_SESSION['old_url'];
else
unset($_SESSION['login_url']);


Replace
if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
$_SESSION['login_url'] = $_SESSION['old_url'];
elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false)
unset($_SESSION['login_url']);
Michael Eshom
Christian Metal Fans

tectonny

I appreciate the attempt, but still does not direct to the home page after login or logoff

Oldiesmann

I honestly don't know why it wouldn't be working still unless $_SESSION is getting reset somewhere along the lines.
Michael Eshom
Christian Metal Fans

Advertisement: