Gruzin Posted January 4, 2007 Share Posted January 4, 2007 Hi guys,Sessions doesn't work on my computer (server), I've changed [b]session.save_path[/b] to [b]c:/windows/temp[/b] in my php.ini, but it doesn't work anyway... any help will be greatly appreciated.Thanks,George Quote Link to comment https://forums.phpfreaks.com/topic/32842-solved-quick-question-about-sessions/ Share on other sites More sharing options...
trq Posted January 4, 2007 Share Posted January 4, 2007 Is your code correct? Does your browser allow cookies?There could be many vairables at play here... what have you done to debug the problem? Quote Link to comment https://forums.phpfreaks.com/topic/32842-solved-quick-question-about-sessions/#findComment-152884 Share on other sites More sharing options...
Gruzin Posted January 4, 2007 Author Share Posted January 4, 2007 Thanks thorpe for your reply...Yes, my browser does allow cookies.The thing is that my code works fine on other servers like Godaddy,aplus.net and etc.But it doesn't work on my computer, I'am using [b]PHP Version 4.3.11[/b] and apache [b]Apache/1.3.33 (Win32)[/b].So I can't figure out the reason....Thanks,George Quote Link to comment https://forums.phpfreaks.com/topic/32842-solved-quick-question-about-sessions/#findComment-152893 Share on other sites More sharing options...
PFMaBiSmAd Posted January 4, 2007 Share Posted January 4, 2007 Have you checked your server log and/or put the following line in after your first opening <?php tag -[code]error_reporting(E_ALL);[/code]What are all the session related settings from your php.ini file?When you say that they don't work, what are they doing and post some code that you have that does not work.I suspect that output buffering is ON on the servers that your code works on and it is off on your development system and that your code is improperly outputting content to the browser prior to your session_start()... Quote Link to comment https://forums.phpfreaks.com/topic/32842-solved-quick-question-about-sessions/#findComment-152932 Share on other sites More sharing options...
Gruzin Posted January 4, 2007 Author Share Posted January 4, 2007 Here is the login script for example wich works fine on other servers:[code]<?phpsession_start();require ("config.php"); //conect to db$myuser = $_POST['user']; // vars from form$mypass = $_POST['pass']; $log = $_POST['list'];switch($log){default:$sql="SELECT * FROM aid_users WHERE user='$myuser' and pass='$mypass'";$result = mysql_query($sql);$count = mysql_num_rows($result);if($count==1){session_register("user");header("location:index.php");}else {header("location:admin.php?login=false");}break;case "admin":$sql="SELECT * FROM aid_users WHERE user='$myuser' and pass='$mypass'";$result = mysql_query($sql);$count = mysql_num_rows($result);if($count==1){session_register("user");header("location:index.php");}else {header("location:admin.php?login=false");}break;case "director":$sql="SELECT * FROM aid_director WHERE user='$myuser' and pass='$mypass'";$result = mysql_query($sql);$count = mysql_num_rows($result);if($count==1){session_register("user");header("location:functions/eng/eng_dir.php");}else {header("location:admin.php?login=false");}break;}?>[/code]My problem is that it doesn't display a registered session...Thanks,George Quote Link to comment https://forums.phpfreaks.com/topic/32842-solved-quick-question-about-sessions/#findComment-152934 Share on other sites More sharing options...
PFMaBiSmAd Posted January 4, 2007 Share Posted January 4, 2007 Use of [b]session_register[/b] is depreciated/obsolete and [b]only[/b] works when register_globals are ON. Quote Link to comment https://forums.phpfreaks.com/topic/32842-solved-quick-question-about-sessions/#findComment-152941 Share on other sites More sharing options...
Gruzin Posted January 4, 2007 Author Share Posted January 4, 2007 Ok, thanks a lot! How can I store info using session in my case (login script)?Regards,George Quote Link to comment https://forums.phpfreaks.com/topic/32842-solved-quick-question-about-sessions/#findComment-152999 Share on other sites More sharing options...
kenrbnsn Posted January 4, 2007 Share Posted January 4, 2007 Instead of [code]<?phpsession_register("user");?>[/code]use[code]<?php$_SESSION['user'] = $user;?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/32842-solved-quick-question-about-sessions/#findComment-153001 Share on other sites More sharing options...
Gruzin Posted January 4, 2007 Author Share Posted January 4, 2007 Thanks Ken,I want to change Register Globals to On ,but It doesn't change anything in phpinfo, I mean register globals are still off.Is there anything I'am doing wrong?Thanks for your help guys,George Quote Link to comment https://forums.phpfreaks.com/topic/32842-solved-quick-question-about-sessions/#findComment-153005 Share on other sites More sharing options...
kenrbnsn Posted January 4, 2007 Share Posted January 4, 2007 [b][color=red]Do not change register_globals to on[/color][/b] Read [url=http://www.php.net/register_globals]this section[/url] in the PHP manual on register_globals. When it's enabled, your code can be compromised very easily if you're not very careful (even if you are very careful).Ken Quote Link to comment https://forums.phpfreaks.com/topic/32842-solved-quick-question-about-sessions/#findComment-153007 Share on other sites More sharing options...
Gruzin Posted January 4, 2007 Author Share Posted January 4, 2007 Thanks again Ken,I've used the way you've talled me and it works just fine! I mean [code]<?php$_SESSION['user'] = $user;?>[/code] doesn't need register globals to be on and that's great!Thanks to all!George Quote Link to comment https://forums.phpfreaks.com/topic/32842-solved-quick-question-about-sessions/#findComment-153009 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.