Simple Machines Community Forum

General Community => Scripting Help => Aiheen aloitti: phpchris - heinäkuu 24, 2007, 04:48:56 AP

Otsikko: Login through an external file in order to realize an ajax-login
Kirjoitti: phpchris - heinäkuu 24, 2007, 04:48:56 AP
Hi champs,

I am trying to realize a login through an external file.
The file gets the login-details via POST.
Here is my code:

if($_POST['user'] && $_POST['pass'])
  {
$length = 3153600;         
$username = addslashes($_POST['user']);
$passwd2 = sha1($_POST['pass']);
    if(smf_setLoginCookie($length, $username, $passwd2, false))
    {
smf_authenticateUser();
smf_loadSession();
$_SESSION = $_COOKIE;
debugo($passwd2);


The SMF-API is included and a cookie with the correct cookie name is set, doesnt seem to be right though!

Any ideas please?
Otsikko: Re: Login through an external file in order to realize an ajax-login
Kirjoitti: phpchris - heinäkuu 25, 2007, 05:34:45 IP
No one?
Otsikko: Re: Login through an external file in order to realize an ajax-login
Kirjoitti: Rick_bbp - heinäkuu 26, 2007, 12:42:42 AP
I have a similar problem (not really) but login, sessions and cookie related. .. Noone replied there as well ...

I havent played with the forum yet but looks like I might be able to help given some time .... elaborate what do you want in the end of the day ?
Otsikko: Re: Login through an external file in order to realize an ajax-login
Kirjoitti: phpchris - heinäkuu 26, 2007, 04:39:09 IP
Hi and thanks for the reply.

I am sending form data via POST to a custom file.
I want to log into SMF from this file. It is realized with ajax.
I have tried around a bit. It seems as if it sets a cookie but the cookie does not seem to be right.
This is my source:


<?php
require('../forum/SSI.php');
if(
$_POST['user'] && $_POST['pass'])
  {
$length 3153600;         
$username addslashes($_POST['user']);
$passwd2 sha1($_POST['pass']);
setLoginCookie(3153600$_POST['user'], $passwd2);
$cookie = @unserialize(stripslashes($_COOKIE[$smf_settings['cookiename']]));
debugo($cookie);
  }


debugo() is a custom function which gives out the values of an array in <pre> Tags.

Any ideas?
Otsikko: Re: Login through an external file in order to realize an ajax-login
Kirjoitti: phpchris - elokuu 03, 2007, 07:18:08 AP
Come on chaps. No one?
Otsikko: Re: Login through an external file in order to realize an ajax-login
Kirjoitti: phpchris - elokuu 09, 2007, 07:41:17 AP
Fellas, what is the problem?
Has no one ever done this?
Otsikko: Re: Login through an external file in order to realize an ajax-login
Kirjoitti: phpchris - elokuu 29, 2007, 02:23:14 AP
Ok, cool...
Anyone has an idea where to get help?
Anyone seen a code-snippet or so?
Otsikko: Re: Login through an external file in order to realize an ajax-login
Kirjoitti: phpchris - syyskuu 01, 2007, 08:50:03 AP
Good, ok cheers...