SSI - $context doesn't register login in from wordpress site

Started by guzh, January 07, 2012, 01:58:44 PM

Previous topic - Next topic

MLM

Quote from: andre nickatina on January 14, 2012, 01:04:03 AM
If the data has slashes in it, you either need to figure out why and make it stop, or more easily edit SSI.php to use stripslashes() before unserializing the cookie data

You could just encode it
base64_encode(serialize($stuff));

My Themes:

My Mods:

Unsolved Threads:
  • None atm...

guzh

Quote from: andre nickatina on January 14, 2012, 01:04:03 AM
So, turn on subdomain independent cookies option in SMF's admin panel. Your cookie needs to be set on path '/'

The SSI.php file will load Settings.php and get the correct cookie name $cookiename so don't worry about having 2 cookies

If the data has slashes in it, you either need to figure out why and make it stop, or more easily edit SSI.php to use stripslashes() before unserializing the cookie data

ah, thanks (: Where/How do I set cookie on path '/' ?

Arantor

If you set subdomain independent cookies, they will have the / path in them.
Holder of controversial views, all of which my own.


Andre N

Quote from: MLM on January 14, 2012, 01:13:12 AM
Quote from: andre nickatina on January 14, 2012, 01:04:03 AM
If the data has slashes in it, you either need to figure out why and make it stop, or more easily edit SSI.php to use stripslashes() before unserializing the cookie data

You could just encode it
base64_encode(serialize($stuff));

Or in php.ini

magic_quotes_gpc = Off


or in .htaccess

php_flag magic_quotes_gpc Off
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

guzh

Quote from: arrowtotheknee on January 14, 2012, 10:15:21 AM
If you set subdomain independent cookies, they will have the / path in them.
but I've already done that.. before I posted the cookie data.
and the SMFCookie665 is still empty. (that's the Cookie Name set in Cookies and Sessions). I've now tried deleting my cookies and start over. and that only resulted in that the other SMFCookie was deleted and is not being created. The SMFCookie665 is still created, but still doesn't return anything when I var_dump $_Cookies in wordpress. But in Firecookie it does.

Sorry for being a bit slow, but I don't understand this at all xD

I guess I'll use stripslashes() as it's the easiest way.


Andre N

Hi, could you pm me a link to your site and a test smf account and I'll be able to tell you if the cookie is set correctly :)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Andre N

Hi,
I checked out your site and logged in and the cookie is correctly set on path '/'. The cookie name is SMFCookie10
I think there is a session conflict between Wordpress and the SMF SSI.php script. Here's an idea. Download the API from here:
http://www.simplemachines.org/community/index.php?topic=453008.0
Copy the function ssi_login() to the bottom of the API and use the API instead.
require it first just like you were doing with the SSI.php script, then call the function ssi_login() like before.
The API won't mess with the Wordpress session, it'll just grab the cookie, load the user info and let you work with it
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

guzh

Hi again,
okey.. I use some of the other functions from the ssi, like ssi_boardNews(), todaysEvents(), todaysHolidays(), ssi_menubar() and ssi_logout(), can I just copy those as well? How about $context? Will that work?

The Cookie is populated correctly when copying the login function to the API :) (it still add those backslashes btw, how do I fix that now?)

and I really don't understand why it works perfectly on a clean install of both WP and SMF. It even makes the SMFCookie without the backslashes.
and with the dump from the client's forum it doesn't.. Is it possible to dump a forum's posts, users, boards, without getting all settings and such? or do I then have to import each table at a time in the db?

Andre N

Ok, if you're using lots of other SSI functions, just abort that idea of using the API and copying them. Some of those functions will have dependencies the API doesn't provide.

If the problem is that the cookie data is being slashed on the client site, in the SSI.php script, try doing something like this before you call the functions:

global $cookiename;
$_COOKIE[$cookiename] = stripslashes($_COOKIE[$cookiename]);


to see if that fixes this
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

guzh

okey, but if I don't use the API, the SMFCookie is not populated correctly xD

I tried including both API and SSI, but that didn't work either. (i renamed the login-function)


so basically I'm back to square one. or now I know a fresh install works. So if anyone know some easy way to export only the necesseray stuff like posts, users and boards it would be great.. (:

Andre N

How is the cookie not populated when you use the SSI? I don't see how it would make a difference.
Both the API and SSI load Settings.php to get the $cookiename so they both are trying to access the same cookie. The cookie is either set or it's not...

Can you send me a temporary ftp and forum account, and tell me what page you're testing it on? I'd be happy to check it out if you like. I really can't visualize what the problem is.

Did you turn magic quotes off?
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

guzh

Quote from: andre nickatina on January 18, 2012, 01:01:37 PM
How is the cookie not populated when you use the SSI? I don't see how it would make a difference.
Both the API and SSI load Settings.php to get the $cookiename so they both are trying to access the same cookie. The cookie is either set or it's not...

Can you send me a temporary ftp and forum account, and tell me what page you're testing it on? I'd be happy to check it out if you like. I really can't visualize what the problem is.

Did you turn magic quotes off?

Sorry for late reply.
When I say "the SMFCookie is not populated correctly" I mean that it is not populated when I var_dump $_Cookie, but it is in Firebug. So the cookie is set, but doesn't contain any information visible when var_dumping.

and it should be visible even if the magic quotes is on, right?

Madchen

Quote from: Andre N on January 09, 2012, 10:53:47 AM
If you can see the SMF cookie from your script, and get the cookie data and unserialize it properly, then this is just a session issue.
Try this:

require_once($_SERVER['DOCUMENT_ROOT'] . '/path/to/SSI.php');
$cookieData = unserialize($_COOKIE[$cookiename]);

if (!isset($_COOKIE[$cookiename])) {
    echo 'unable to see SMF cookie';
}

if (!$cookieData) {
    echo 'failed to unserialize SMF cookie';
} else {
    echo '<pre>;
    print_r($cookieData);
    echo '</pre>';
}


to see if you can actually get the information out of the cookie. If you get the message you can't see the cookie, it's not being set on the correct path. If you can't unserialize it, then we can try to figure out why not.
If you can get the cookie data, there's a session issue. Tell me what exactly you're trying to accomplish and I'll tell you how to do it with the API rather than through SSI

Same problem Wordpress+ SMF.

After ticking "Use subdomain independent cookies" unable to see SMF cookie error dissapear;

Then i've got this one:
Quotefailed to unserialize SMF cookie
.

Now, i'm not sure where should i put this line
Quoteecho $_COOKIE[$cookiename];

If i try to var_dump($_COOKIE[$cookiename];), returns NULL.
Login/logout works and other functions.

Madchen

Dunno if this can help but cookie from loclahost where everything works:

And from server:

Madchen

Big thanks to this guy hxxp:sleepycode.com/2012/01/smf-in-wordpress/ [nonactive]. He solved problem.

After this line in  ssi.php
Quote// Get the forum's settings for database and file paths.
require_once(dirname(__FILE__) . '/Settings.php');
I added this
Quoteif (isset($_COOKIE[$cookiename]))
      $_COOKIE[$cookiename] = stripslashes($_COOKIE[$cookiename]);

Now one more thing. Logout on forum doesn't work. Its not a big deal after this, but any ideas?


Advertisement: