Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 19th, 2003, 01:01 AM
Registered User
 
Join Date: Nov 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP session_start(); doesn't work on webserver

Hey guys,

I am having a problem with using this code on my webhost providers server:
<?
session_start();
$valid = "yes";
$_SESSION[valid] = $valid;
?>
<HTML>
<-- rest of code -->
</HTML>

They are using Windows NT, IIS/5.0, PHP 4.3.3 with register_global ON, and session.auto_start OFF

This is a letter that I wrote to my webhost provider:

----- Original Message -----
From: ShredDead-Metal
To: [email protected] ; [email protected]
Sent: Sunday, November 16, 2003 8:13 PM
Subject: Still having problem with PHP's start_session();


Hi,

I was wondering if the problem with me using PHP's sessions was fixed? This is the code I am using:

<?
session_start();
$valid = "yes";
$_SESSION[valid] = $valid;
?>
<HTML>
<-- rest of code -->
</HTML>

This page, among the rest of my session_start(); pages, works without one problem on my localhost system that uses Windows XP, Apache 1.3.24 and PHP 4.3.4. All I did was transfer it over to yours. The only difference between mine and yours is that my PHP.INI file under Sessions is this:

session.save_path = C:\WINDOWS\Temp

This is the complete error that comes up on my page when I try to use the above script:

Warning: session_start(): open(C:\PHP\sessiondata\sess_a56ce3d506d5fb7035a0a 650071364cf, O_RDWR) failed: No such file or directory (2) in d:\websites\ShredDead-Metal\main_page.php on line 2

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at d:\websites\ShredDead-Metal\main_page.php:2) in d:\websites\ShredDead-Metal\main_page.php on line 2

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at d:\websites\ShredDead-Metal\main_page.php:2) in d:\websites\ShredDead-Metal\main_page.php on line 2

Notice: Use of undefined constant valid - assumed 'valid' in d:\websites\ShredDead-Metal\main_page.php on line 4

Warning: Unknown(): open(C:\PHP\sessiondata\sess_a56ce3d506d5fb7035a0a 650071364cf, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\PHP\sessiondata) in Unknown on line 0

Thanks for working with me
__________________________________________________ _______________________________________
Their response:

Hi:
    We apologize for the delayed response. The path has been set to the correct directory. It seems the script is not reading the directory correctly. Session data is working correctly since we do see log files been written in.
__________________________________________________ _______________________________________

Is there something that I have done wrong or is it my provider. If the problem is them how do I go about fixing this. I would hate to know that my hard work has been left flat-lined due to them.

Thanks,
ShredDead
 
Old November 19th, 2003, 02:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay, one of your warnings is because you're not quoting your array index.

$_SESSION[valid]

   should be:

$_SESSION['valid']

PHP sends this error to the browser as output, which causes the default HTTP headers to be sent and prevents you from being able to send additional header information.


Now, on to your "main" problem: the directory was in all likelyhood created by your web hosting company, but they didn't say anything about having verified that permissions were set properly for your domain. Perhaps the session data they see in that directory is from another PHP-generated web site they host.

They say that "log files" have been written in, but I see no reason to assume that these log files are actually your session data files. Here's one way to test (if you're still having problems): Get them on the phone, tell them to run your script, which should create that error message. Ask them to verify that the session file specified in the error exists and is nonempty in their sessiondata directory.

The session data file in your original post is sess_a56ce3d506d5fb7035a0a650071364cf, and it's in the C:\PHP\sessiondata\ directory.


Take care,

Nik
http://www.bigaction.org/
 
Old November 19th, 2003, 06:02 PM
Registered User
 
Join Date: Nov 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Nikolai,

I will make this correction in my script, take your suggestions and get ahold of my webhost provider. I can't believe that the purchaser has to police the company to know that he/she is getting all the service the require. Especially when they offer PHP services.

ShredDead






Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting to a remote webserver using php sapphire87 PHP How-To 0 July 21st, 2006 12:05 PM
PHP Oracle At Work Spirabhu PHP Databases 0 June 29th, 2005 04:35 AM
session_start doesn't work in IE on my server dsmarr BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 April 8th, 2005 06:06 AM
php does not work help!!! p2ptolu PHP How-To 2 March 23rd, 2005 03:51 AM
making php work? P.Y.sum Beginning PHP 5 November 5th, 2003 10:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.