News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Variables

Started by chris077, August 14, 2009, 09:30:44 PM

Previous topic - Next topic

chris077

I figured it out..

Arantor

First up, did you include SSI.php as the first thing on the page? That can prevent logins working as expected.

Secondly, you can actually have it redirect wherever you want after a successful login by adding this after the include of SSI.php:

$_SESSION['login_url'] = 'http://where-i-want-to-go-back-to.com/'

chris077

I did both of those, and it still shows up as im a guest.

The code you gave does not work but in SSI.php i edited ..


function ssi_login($redirect_to = 'http://**/index.php', $output_method = 'echo')

Arantor

You don't edit SSI.php.

Literally:

<?php
include('SSI.php');
$_SESSION['login_url'] = 'http://**/index.php';

ssi_login();


The redirect_to parameter is broken in SMF 2. It's a known bug. You therefore have to work around it as I've shown.

chris077

Quote from: Arantor on August 14, 2009, 10:15:25 PM
You don't edit SSI.php.

Literally:

<?php
include('SSI.php');
$_SESSION['login_url'] = 'http://**/index.php';

ssi_login();


The redirect_to parameter is broken in SMF 2. It's a known bug. You therefore have to work around it as I've shown.
it still redirects me to the forum..And shows as a guest when i go back to homepage.

Arantor


chris077


Arantor

It's a resurgence of a bug in SMF 2.

Basically when it gets into the ssi_login function it actually drops the value out of the session, so you get this.

The solution is to set the session variable as I have indicated, and simply display the login form yourself. ssi_login contains the form variables, just bring that outside into your code, then you can style it as you like, and it should work.

chris077

I dont really understand what you mean..


<?php
$_SESSION
['login_url'] = '**/index.php';
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">Username:</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">Password:</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="Login" /></td>
</tr>
</table>
</form>'
;
?>


Kays

You need to include SSI.php before you set the session.


<?php
require_once('server_path_to_SSI.php');
$_SESSION['login_url'] = '**/index.php';
echo 
'
<form action="'
$scripturl'?action=login2" method="post" accept-charset="'$context['character_set'], '">

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

chris077

I did I just didn't include it in my post. I'm still lost..

chris077

#11
I just moved all my files into the same directory as the forum so now it works. Thanks for trying to help though guys. I appreciate it!

Wait...now how do i reset the forum so it uses community.php instead of index.php..?

Arantor

If you really want to rename it, this is doable, though not entirely recommended for a variety of reasons.

Though if you did want to do so, this has been done before - it's documented in Tips & Tricks somewhere, with the replies documenting the caveats to doing it - you'd be best looking through there first and then opening a new topic since this is a different thing entirely.

chris077

Thanks...I got that done but another question..

How would I use register on my website? I tried adding the ssi_register mod onto the SSI.php but its for 1.1.10 so it doesn't display the text or the right forms for 2.0..

Any help?

Arantor

SSI Register needs updating for 2.0. I volunteered to take it though I haven't had chance to actually do this yet.

chris077

Is there any other way to do this?

Arantor

What exactly do you want to do?

If you want to use the registration form, you either have to direct to the forum, or wait for SSI Register to be updated to 2.0.

chris077

Can I not somehow get the form from the smf files?

Arantor

That's what SSI Register does. It drops the form into your own page.

What exactly are you trying to do with Register()?

Orstio

Quote from: chris077 on August 15, 2009, 01:41:32 AM
I just moved all my files into the same directory as the forum so now it works. Thanks for trying to help though guys. I appreciate it!

Wait...now how do i reset the forum so it uses community.php instead of index.php..?

Make sure subdomain independent cookies is enabled in SMF, and it won't matter which directory your file is in.

chris077

Quote from: Arantor on August 15, 2009, 09:00:23 PM
That's what SSI Register does. It drops the form into your own page.

What exactly are you trying to do with Register()?
I understand that but its not for 2.0...and i dont really have time to wait for it to come out for 2.0..

I just trying to get the register form on my website so people can register on the website instead of the forum..

Arantor

SSI Register was not part of 2.0 nor part of 1.1 without a mod. You are either waiting for someone to upgrade the mod, or learn how to splice templates from 2.0 into your code.

I will take a look at upgrading SSI Register for 2.0 in the next couple of days - unless someone else wants to jump in (but I strongly doubt it)

chris077

Ok my login is still going to the forums.. Any help? This is a include file, I include it into the login box on every page..that might have something to do with it?

My forum is community.php and my homepage is index.php..


<?php
require_once('SSI.php');
$_SESSION['login_url'] = '****/index.php';
if (
$context['user']['is_guest'])
{
   
ssi_login('****/index.php');
}
else
{
   
//stuff

   
ssi_logout();
}
?>


Arantor

If you're using 2.0 there is a known bug where the session variable isn't properly maintained when using ssi_login, thus you have to pull the form out of ssi_login and display it yourself.

chris077

Quote from: Arantor on August 16, 2009, 01:53:48 PM
If you're using 2.0 there is a known bug where the session variable isn't properly maintained when using ssi_login, thus you have to pull the form out of ssi_login and display it yourself.
Theres no way to direct every login on the forums? not just the SSI?

Arantor

What exactly are you trying to do?

You were using SSI.php for the purposes of directing back to a site after logging in from the site, correct? Are you saying that you want to return to the non-forum page after successful login regardless of whether it's in the forum or outside it?

chris077

#26
Quote from: Arantor on August 16, 2009, 06:07:17 PM
What exactly are you trying to do?

You were using SSI.php for the purposes of directing back to a site after logging in from the site, correct? Are you saying that you want to return to the non-forum page after successful login regardless of whether it's in the forum or outside it?
That is correct.

edit: i just added this at the top of LogInOut.php

$_SESSION['login_url'] = '****/index.php';
$_SESSION['logout_url'] = '****/index.php';

Arantor

That would have been what I would advise you next, yes - if you want to force all users to return to a page other than the forum index on login - not just from outside via ssi_login but *all* logins, that's the only way to do it.

chris077

Another problem..when i click on the ssi_logout.

Session verification failed. Please try logging out and back in again, and then try again.

Arantor

Does the link that ssi_logout produce have a long string of alphanumeric characters in it?

chris077

Yes.
its the wrong session ID i think..

community.php?action=logout;dcf037cba53=e002ebf8ee0d66ff271959dbc974d07a

I made a nav item using ssi_logout on the forum and it worked fine, it was a different session id.

jollyrogue

this is the exact same problem i'm also having
http://www.simplemachines.org/community/index.php?topic=331264.msg2215670#msg2215670

Login redirects to the forum and logout brings up a session verification failed.

Frieling

instead of having include_once('SSI.php');

i always found include('SSI.php');

is alittle easier and cleaner, just a little coding assist
Just an average guy.

Orstio

Quote from: chris077 on August 16, 2009, 07:18:45 PM
Yes.
its the wrong session ID i think..

community.php?action=logout;dcf037cba53=e002ebf8ee0d66ff271959dbc974d07a

I made a nav item using ssi_logout on the forum and it worked fine, it was a different session id.

After you include SSI.php, you need this code:

global $context;

$sc = &$context['session_id'];
$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];

Advertisement: