master82 Posted February 21, 2007 Share Posted February 21, 2007 I have the following simple login authentication script... <?php session_start(); include "database.php"; if ($_POST['email'] == "" || $_POST['password'] == "") { die("You did not fill in the login form!<br> <a href=login.php>-Back-</a>"); } $mc=mysql_query("SELECT mid FROM members WHERE memail='{$_POST['email']}' AND mpassword=md5('{$_POST['password']}')"); if(mysql_num_rows($mc)!=1) { die("Invalid email or password!<br> <a href=login.php>-Back-</a>"); } else { $_SESSION['log']=1; $m=mysql_fetch_row($mc); $_SESSION['member']=$m['mid']; $IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; mysql_query("UPDATE members SET mlastip='$IP',mlaston=unix_timestamp() WHERE mid={$m['mid']}"); } //header("Location: index.php"); print"LS - {$_SESSION['log']}<p>MS - {$_SESSION['member']}<p>Mid - {$m['mid']}"; ?> However I did not seem to carry the session information over, so I removed the redirect and printed the values instead: Session - log = 1 Session - member = *blank* $m['mid'] = *blank* Anyone help? Link to comment https://forums.phpfreaks.com/topic/39415-solved-session-trouble/ Share on other sites More sharing options...
tom100 Posted February 21, 2007 Share Posted February 21, 2007 So the variables did output on the first page? If so, that would make sense, cause you simply set a variable, not really a session yet. On the next page, make sure you have session_start at the top, then test it on the second page. Link to comment https://forums.phpfreaks.com/topic/39415-solved-session-trouble/#findComment-190157 Share on other sites More sharing options...
master82 Posted February 21, 2007 Author Share Posted February 21, 2007 No, its not setting $m['mid'] which in turn doesnt set the session member. Link to comment https://forums.phpfreaks.com/topic/39415-solved-session-trouble/#findComment-190160 Share on other sites More sharing options...
Archadian Posted February 21, 2007 Share Posted February 21, 2007 tom100 suggested i set session.use_only_cookies = 1 to ; session.use_only_cookies = 1 in your php.ini file worked for me... Link to comment https://forums.phpfreaks.com/topic/39415-solved-session-trouble/#findComment-190161 Share on other sites More sharing options...
tom100 Posted February 21, 2007 Share Posted February 21, 2007 ok, try doing this: after your query, run a while loop while ($query=mysql_fetch_array($mc)) { print_r($query); } See what columns are being returned and their values. Link to comment https://forums.phpfreaks.com/topic/39415-solved-session-trouble/#findComment-190163 Share on other sites More sharing options...
master82 Posted February 21, 2007 Author Share Posted February 21, 2007 i figured it out, I used fetch_assoc and not fetch_row. Thanks anyway people Link to comment https://forums.phpfreaks.com/topic/39415-solved-session-trouble/#findComment-190166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.