Issue On Setting Session Using Ajax, jQuery, and PHP -
I am trying to create a simple Ajax login system and I have a jQuery Ajax call in login.php:
if (proceed) {var data = 'email =' + tempEmail + '& amp; Pass = '+ tempPass; Var loginreq = $ Axx ({type: "post", url: "asset / temps .fp", cache: false, data: data}); Loginreq.done (function (html) {if (html == 'true') {window.location.replace ('app.php');} and {$ ("# loginRequest"). First ('& lt; div Class = "alert alert-hazard error" role = "alert"> email or password is not correct ;)}}}); } tempusers.php is like the file: = 1) {echo 'true'; $ _SESSION ['uName'] = $ line ['uName'];} Else {echo 'false' ;}? & Gt; and in my app.php I have
& lt ;? php session_start (); if (! _ Session ['yum']) {header ('location: login.php');}? & Gt; & gt; DOCTYPE html & gt; & lt; html lang = "en" & gt; & lt; Top & gt; Title & gt; Secret Land & lt; / title & gt; & lt; / head & gt; Body & gt; & lt; h1 & gt; Hi This App & lt;/ H1 & gt; & gt; / body & gt; & lt; / html> I'm sure I'm putting the correct user e-mail password in the box, But the app.php is not showing! I can not find an error message
When I remove the starting portion of the app.php from the page, then everything works fine!
& lt ;? Php session_start (); If (empty! ($ _ Session ['yum']) {header ('location: login.php'); }? & Gt; Can you please tell me what I am doing wrong and what is the reason for this problem?
If valid login
$ _ session ['uName'] = $ Line ['uName']; So yes, it is not empty
if (! ($ _ Session ['uName'])) Assume this should be
(empty ($ _ session ['uName'])) Is correct? :)
Comments
Post a Comment