aladdin249 Posted March 7, 2008 Share Posted March 7, 2008 Using PHP 4.4.6 in PHP.ini (session area) Session Support enabled Registered Save Handelers files user login.php: <? session_start(); .. some other php code session_start(); $_SESSION['user_login'] = 1; session_register('user_login'); header ("Location: http://siteAddress/index.php"); .. some other php code ?> in index.php <? session_start(); .. some other php code if (isset($_SESSION["user_login"]) && ($_SESSION["user_login"]) == 1 ) { echo 'I am logged on'; } else { echo 'I am NOT logged on'; } .. some other php code ?> Whet it re-directs to index.php, it always shows me 'I am NOT logged on' instead of 'I am logged on' Any help? Thanks Quote Link to comment Share on other sites More sharing options...
revraz Posted March 7, 2008 Share Posted March 7, 2008 Remove the 2nd session_start() in login.php, remove session_register('user_login'); In index.php, echo $_SESSION['user_login'], if its empty, check your session save path in your php.ini Don't direct to a absolute URL like http://siteAddress/index.php, but instead direct to index.php. If you go to login.php with www.siteAddress.com and it directs to siteAddress.com, they are not the same and the session will be different. Quote Link to comment Share on other sites More sharing options...
aladdin249 Posted March 7, 2008 Author Share Posted March 7, 2008 ThANKSSSSSSSSSSSSS - it worked A short follow-up Q? The session-path in php.ini is: session.save_path = ".\" Now I have to check if session works with other files in subdirectories as well. Would you suggest anything with the path? or any suggestion for the .php files sitting in the subdirectories. Thanks Again!!!!! Quote Link to comment Share on other sites More sharing options...
conker87 Posted March 7, 2008 Share Posted March 7, 2008 ".\" is the current directory, so would changing it to "\" work? Not got much experience with the ini files. Quote Link to comment Share on other sites More sharing options...
revraz Posted March 7, 2008 Share Posted March 7, 2008 I always make mine a static folder, like phpsessions. Quote Link to comment Share on other sites More sharing options...
aladdin249 Posted March 7, 2008 Author Share Posted March 7, 2008 It did work for the two files I mentioned above. These two files (login.php, index.php) are in the base dir. But now when I check my $_SESSION in the subdirectory, it is not recognizing?? i.e www.sitename.com/html/anotherfile.php and login.php, index.php are in the main dir (www.sitename.com) This what I have for php.ini (or provide from the host provider): [session] session.save_handler = files session.save_path = ".\" session.use_cookies = 1 session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.serialize_handler = php session.gc_probability = 1 session.gc_divisor = 1000 session.gc_maxlifetime = 1440 session.bug_compat_42 = 0 session.bug_compat_warn = 1 session.referer_check = session.entropy_length = 0 session.entropy_file = session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 0 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" Any idea???? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 7, 2008 Share Posted March 7, 2008 session.save_path should be an absolute path not a relative path. Set the session.save_path directive within the php.ini to: session.save_path = "C:/php_sessions/ Create the folder php_sessions within the root of the C: drive. Save php.ini and restart your server (Apache or IIS). Retest your scripts and your sessions should work. Quote Link to comment 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.