popcornplya Posted February 15, 2009 Share Posted February 15, 2009 I have a script I'm working on, and the session variables are empty when I don't have www. in my url, any help? Is this a php issue? Quote Link to comment https://forums.phpfreaks.com/topic/145261-session-issue/ Share on other sites More sharing options...
popcornplya Posted February 15, 2009 Author Share Posted February 15, 2009 Sorry, can't edit.. but my client is using godaddy hosting if that helps. Quote Link to comment https://forums.phpfreaks.com/topic/145261-session-issue/#findComment-762574 Share on other sites More sharing options...
drisate Posted February 15, 2009 Share Posted February 15, 2009 looks like a script config problem...but with no code, no way to help you out ... Quote Link to comment https://forums.phpfreaks.com/topic/145261-session-issue/#findComment-762577 Share on other sites More sharing options...
popcornplya Posted February 15, 2009 Author Share Posted February 15, 2009 Login.php <?php session_start(); if($_SESSION['logged_in']==true) { header("Location: index.php"); exit; } $user = $_POST['user']; $pass = md5($_POST['pass']); if($user && $pass) { include("config.php"); $user = mysql_real_escape_string($user); $user = htmlentities($user); $sql = mysql_query("SELECT * FROM `users` WHERE `username`='$user' && `password`='$pass'"); if(mysql_num_rows($sql)==1) { $_SESSION['logged_in']=true; $_SESSION['user']=$user; header("Location: index.php"); exit; } else { header("Location: index.php?e=1"); exit; } } else { header("Location: index.php"); } ?> Other pages: <?php session_start(); if($_SESSION['logged_in']) { echo '<p>Welcome, '.$_SESSION['user'].'</p>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/145261-session-issue/#findComment-762579 Share on other sites More sharing options...
genericnumber1 Posted February 15, 2009 Share Posted February 15, 2009 Try setting your session.cookie_domain in your php.ini to be mydomain.com (no www.)... see if that helps at all. It's likely that the session ID isn't being sent, but I'm not sure what the default cookie domain is for sessions. Quote Link to comment https://forums.phpfreaks.com/topic/145261-session-issue/#findComment-762580 Share on other sites More sharing options...
popcornplya Posted February 15, 2009 Author Share Posted February 15, 2009 How do you edit ini's on shared hosting? Sorry I'm not a PHP pro so if I ask any stupid questions please excuse me. Quote Link to comment https://forums.phpfreaks.com/topic/145261-session-issue/#findComment-762589 Share on other sites More sharing options...
genericnumber1 Posted February 15, 2009 Share Posted February 15, 2009 There are very few stupid questions I'm sure on your shared hosting panel there is probably some option to edit your php.ini - I don't use godaddy, so I don't know how you would do it with them. Quote Link to comment https://forums.phpfreaks.com/topic/145261-session-issue/#findComment-762591 Share on other sites More sharing options...
Cory94bailly Posted February 15, 2009 Share Posted February 15, 2009 How do you edit ini's on shared hosting? Sorry I'm not a PHP pro so if I ask any stupid questions please excuse me. I used godaddy before my friend got a dedicated server (free for me >:])... In your root directory, make a new file called "php.ini" (in some cases, try "php5.ini") Quote Link to comment https://forums.phpfreaks.com/topic/145261-session-issue/#findComment-762605 Share on other sites More sharing options...
popcornplya Posted February 15, 2009 Author Share Posted February 15, 2009 Thanks for your help guys, but I just fixed this with htaccess (made it redirect to www.) Quote Link to comment https://forums.phpfreaks.com/topic/145261-session-issue/#findComment-762609 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.