Forum Moderators: coopster

Message Too Old, No Replies

Apparent Conflict

in code I'm trying to save

         

old_expat

12:58 am on Aug 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let me preface this with:

1 - I am not a programmer, just able to poke my way around some simple code

2 - Half way through a project, the coder decided he was tired of the project .. but not so tired that he gave me a partial refund.;)

I seem to be getting a conflict and hoping someone can help me out.

Warning: Cannot modify header information - headers already sent by (output started at /home/username/public_html/index.php:11) in /home/username/public_html/includes/general.php on line 297

[line 297 of general.php]

setcookie($name, $value, $expire, $path, (cdh_not_null($domain)? $domain : ''), $secure);
}

There "seems" to be a conflict:

in index.php

<?
require('includes/application_top.php');

global $messageStack;

# This program is the default page for the ******** site.
# Directories are implemented as fixed searches for a city, state, metro area, etc.
#
# Inputs/Actions:
#
#RequestpIDpaIDuID
#noneignoredignoredignored

$srcharry['property_is_motel'] = 1;
$srcharry['property_is_hotel'] = 1;
$srcharry['property_is_bb'] = 1;
$srcharry['property_is_speciality'] = 1;

?>

in application_top.php

// start the session
$session_started = false;
if (SESSION_FORCE_COOKIE_USE == 'True') {
cdh_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain);

if (isset($HTTP_COOKIE_VARS['cookie_test'])) {
session_start();
$session_started = true;
}
} else {
session_start();
$session_started = true;
}

Psychopsia

1:14 am on Aug 30, 2006 (gmt 0)

10+ Year Member



Ensure to not have a white space or line before the opening tag "<?php" or ending tag "?>" on that files.

Cookies are not set if non php code is sent before the cookie header.

eelixduppy

1:24 am on Aug 30, 2006 (gmt 0)




setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace.

http://us2.php.net/setcookie

A fix for this could include using a buffer.(ob_start [us2.php.net] and ob_end_flush [us2.php.net])

Best of luck!

old_expat

6:31 am on Aug 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Guys,

When I moved the code above the <html> tag, that worked .. many thanks.

But now I found "the next" problem:

(there is a /tmp folder)

I'm getting a

Warning: session_start(): open(/home/username/tmp/sessions//sess_11acf466d7ca056c2dde77612540d2cd, O_RDWR) failed: No such file or directory (2) in /home/username/public_html/includes/application_top.php
on line 66

When I start trying to trace the thing, I get to one file called configure.php This looks like it belongs, but something must be wrong because of the "sessions"

(are some of those lines of code "template" stuff?)

<?php

define('SITE_NAME', 'My Site');
define('QUERY_DEBUG', 'On');
define('NOTIFY_TO', 'Webmaster <contact@mysite.com>');// where to send the notification email.
define('NOTIFY_FROM', 'Webmaster <contact@mysite.com>');// sender of the notification email.

// Define the webserver and path parameters
// * DIR_FS_* = Filesystem directories (local/physical)
// * DIR_WS_* = Webserver directories (virtual/URL)
define('HTTP_SERVER', 'http://www.mysite.com');
define('HTTPS_SERVER', 'https://www.mysite.com'); //
define('ENABLE_SSL', false);
define('HTTP_COOKIE_DOMAIN', 'www.mysite.com');
define('HTTPS_COOKIE_DOMAIN', 'www.mysite.com');
define('HTTP_COOKIE_PATH', '/');
define('HTTPS_COOKIE_PATH', '/');

define('DIR_WS_ADMIN', 'admin/');
define('DIR_WS_INCLUDES', 'includes/');
define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');

define('DIR_FS_ROOT','/home/mysite/');
define('DIR_FS_BACKUP', DIR_FS_ROOT .'backups/');
define('DIR_FS_DOWNLOAD', DIR_FS_ROOT .'download/');
define('DIR_FS_TMP', DIR_FS_ROOT .'tmp/');
define('DIR_FS_SESSIONS', DIR_FS_TMP .'sessions/');

define('DIR_FS_DOC_ROOT',DIR_FS_ROOT .'public_html/');
define('DIR_FS_HOTEL_IMAGES',DIR_FS_DOC_ROOT . 'img/hotels/');
define('DIR_FS_INCLUDES',DIR_FS_DOC_ROOT .'includes/');
define('DIR_FS_LISTS', DIR_FS_DOC_ROOT .'menu/');
define('DIR_FS_CLASSES',DIR_FS_INCLUDES .'classes/');

// define our database connection
define('DB_SERVER', 'localhost'); // eg, localhost - should not be empty for productive servers
define('DB_SERVER_USERNAME', 'mysite');
define('DB_SERVER_PASSWORD', 'password');
define('DB_DATABASE', 'mysite_databasedb');

// Used in the "Backup Manager" to compress backups
define('LOCAL_EXE_GZIP', '/usr/bin/gzip');
define('LOCAL_EXE_GUNZIP', '/usr/bin/gunzip');
define('LOCAL_EXE_ZIP', '/usr/local/bin/zip');
define('LOCAL_EXE_UNZIP', '/usr/local/bin/unzip');

// define some values that were configuration values in osC but are fixed for MySite
define('SESSION_FORCE_COOKIE_USE',true);
define('SESSION_BLOCK_SPIDERS',false);
define('SESSION_CHECK_SSL_SESSION_ID',true);
define('SESSION_CHECK_USER_AGENT',true);
define('SESSION_CHECK_IP_ADDRESS',true);
define('SEND_EMAILS',true);
define('CHARSET','iso-8859-1');

// define database table names
define('TABLE_CONFIGURATION', 'configuration');
define('TABLE_PARTNER_ACCOUNTS', 'partner_accounts');
define('TABLE_PROPERTY_DETAILS', 'property_details');
define('TABLE_PROPERTY_WEBPAGE', 'property_webpage');
define('TABLE_CHAINS', 'zchains');
define('TABLE_COUNTRIES', 'zcountries');
define('TABLE_USERS', 'users');
?>

and another called filenames.php. Looks like it was part of the smarty templates setup .. or maybe just part of it?

<?php
// define the filenames used in this project

define('FILENAME_DEFAULT', '/index.php');
define('FILENAME_CREATE_CONFIG', '/admin/create_config_variable.php');
define('FILENAME_PARTNER_ACCOUNT', '/partner_account.php');
define('FILENAME_PARTNER_ACCOUNT_CREATE', '/partner_account_create.php');
define('FILENAME_PARTNER_ACCOUNT_CREATE_SUCCESS', '/partner_account_create_success.php');
define('FILENAME_PARTNER_ACCOUNT_EDIT', '/partner_account_edit.php');
define('FILENAME_PARTNER_ACCOUNT_EDIT_SUCCESS', '/partner_account_edit_success.php');
define('FILENAME_PARTNER_ACCOUNT_FORGOT_PASSWORD', '/partner_account_forgot_password.php');
define('FILENAME_PARTNER_ACCOUNT_LOGIN', '/partner_account_login.php');
define('FILENAME_PARTNER_ACCOUNT_MENU', '/partner_account_menu.php');
define('FILENAME_PROPERTY_DETAILS', '/property_details.php');
define('FILENAME_PROPERTY_DETAILS_CONFIRM', '/property_details_confirm.php');
define('FILENAME_PROPERTY_DISPLAY', '/property_display.php');
define('FILENAME_PARTNER_STATUS_CHANGE', '/admin/partner_status_change.php');
define('FILENAME_PROPERTY_WEBPAGE', '/property_webpage.php');


I deleted this portion

define('FILENAME_TALK', '/IM_talk.php');
define('FILENAME_TALK_CHAT', '/IM_talk_chat.php');
define('FILENAME_TALK_LOG', '/IM_talk_log.php');
define('FILENAME_TALK_LOGIN', '/IM_talk_login.php');

define('FILENAME_LIST_AIRPORTS', 'list_airports.tpl');
define('FILENAME_LIST_COUNTRIES', 'list_countries.tpl');
define('FILENAME_LIST_CHAINS', 'list_chains.tpl');
define('FILENAME_LIST_METRO_AREAS', 'list_metro_areas.tpl');
define('FILENAME_LIST_PROPERTY_IS', 'list_property_is.tpl');
define('FILENAME_LIST_PROPERTY_PRICE', 'list_property_price.tpl');
define('FILENAME_LIST_PROPERTY_TYPE', 'list_property_type.tpl');
define('FILENAME_LIST_US_STATES', 'list_us_states.tpl');


define('FILENAME_LOG_FILE', 'cdhlog.log');

?>

Steerpike

6:43 am on Aug 30, 2006 (gmt 0)

10+ Year Member




Ah the joys of other peoples' code.

Try changing:
define('HTTP_COOKIE_PATH', '/');
define('HTTPS_COOKIE_PATH', '/');

To:
define('HTTP_COOKIE_PATH', '');
define('HTTPS_COOKIE_PATH', '');

It's pretty hard to tell what's going on though.

Psychopsia

2:12 pm on Aug 30, 2006 (gmt 0)

10+ Year Member



You need to create the tmp directory with read/write access. Or define the directory path in php.ini. Under the session.save_path directive. The default should be C:\PHP\sessiondata Or drive letter whereever PHP is installed.

If you do not see this directive in that file, then add it as follows:

session.save_path = C:\PHP\sessiondata