jQuery login moet 2x inloggen voor sessie

Gestart doorMilan2 reacties32 weergaven

3 berichten · pagina 1 van 1

Milan

Lid · Topicstarter

Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

Ik heb een jQuery login gemaakt en via $.get(); word een bestandje aangeroepen met een paar $_GET variabeles met onder andere inlognaam en wachtwoord. Dit is het bestandje:

Session_start(); staat in config

[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]/**
 * 
 * @author Milan Drossaerts
 * @copyright 2012 M. Drossaerts
 * 
 */[/COLOR] 
 
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]includes/config.php[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$leden[/COLOR][COLOR= #007700]->[/COLOR]isLoggedIn[COLOR= #007700]())
{[/COLOR]
    
    [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Location: "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]siteUrl [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"home.php"[/COLOR][COLOR= #007700]);[/COLOR]
    
    [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uName[/COLOR][COLOR= #007700]]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uWachtwoord[/COLOR][COLOR= #007700]]))
{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]2[/COLOR][COLOR= #007700];[/COLOR]
    
    [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700];
    
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    
    [COLOR= #0000BB]$lQuery[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id, gebruikersnaam FROM leden WHERE gebruikersnaam = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]escape[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uName[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" AND wachtwoord = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]escape[COLOR= #007700]([/COLOR][COLOR= #0000BB]$core[/COLOR][COLOR= #007700]->[/COLOR]safePassword[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uWachtwoord[/COLOR][COLOR= #007700]])) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]num_rows[COLOR= #007700]([/COLOR][COLOR= #0000BB]$lQuery[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
    {[/COLOR]
        
        [COLOR= #0000BB]$lFetch[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]fetch[COLOR= #007700]([/COLOR][COLOR= #0000BB]$lQuery[/COLOR][COLOR= #007700]);[/COLOR]
        
        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]]                =[/COLOR] [COLOR= #0000BB]$lFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uGebruikersnaam[/COLOR][COLOR= #007700]]    =[/COLOR] [COLOR= #0000BB]$lFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]];[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]1[/COLOR][COLOR= #007700];
        
    }[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]2[/COLOR][COLOR= #007700];
        
    }
    
}[/COLOR]

?>


Het probleem is dus nu dat soms de sessie niet word aangemaakt, en als je via de login word doorgestuurd naar de pagina, dat je dan weer word teruggestuurd naar de inlog pagina omdat je niet ingelogd bent.

Ook is het soms zo dat hij 1 pagina laad, en dan een andere pagina die in de div geladen word via $.get, dat daar het inlogscherm weer in komt.

Weet iemand waar dit aan kan liggen?

Alvast bedankt,
Milan Drossaerts
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
kan het zijn dat hij op www. word aangeroepen en je bent op de site zonder www?
0
Milan

Lid · Topicstarter

Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Smiegles schreef:
kan het zijn dat hij op www. word aangeroepen en je bent op de site zonder www?
Youre my hero emo
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren