Subject: Ch. 2 - Passing Variables with Sessions
Posted By: tks001 Post Date: 2/19/2006 2:52:32 PM
Working on the first "Passing the Visitor's Username".  Using Windows XP, PHP 5.1.2, Apache 2.1, kept getting "headers already sent" warning when viewing movie1.php.

What worked for me:

1.  Created the c:\tmp directory (I don't know if this is still necessary)

2.  Located php.ini file in c:\windows

3.  Changed "session.auto_start = 0" to " = 1"

4.  Saved the php.ini file

5.  Deleted session cookie in my browser, closed browser

6.  Restarted Apache (to get the changed php.ini info)

7.  Voila!  success ... hope this saves someone 24 hair pulling hours

Here is the background for those of you who are readers.

Kept getting the "headers already sent" Warning.  I found this valuable insight at

http://phpbuilder.com/manual/en/ref.session.php#ini.session.save-path

Note:  Prior to PHP 4.3.6, Windows users had to change this variable in order to use PHP's session functions. A valid path must be specified, e.g.: c:/temp.

In other words, you don't have to specify a path for session.save_path in your php.ini file as advised in paragraph 5, p. 47.

What you DO have to do though, is to is to set session.auto_start

; Initialize session on request startup.
session.auto_start = 1

The default setting is session.auto_start = 0.

I found another post saying changing session.cookie_path -

; The path for which the cookie is valid.
session.cookie_path = /

to "session.cookie_path = \" worked for them.  

It works with the default setting.  Don't waste your time on that one for the first example.

Now on to passing the username with a cookie.  Settings in php.ini may have to be changed again :)

Reply By: tks001 Reply Date: 2/20/2006 6:26:25 PM
Even though that worked, I now know the easier solution is to set encoding in Notepad to ANSI when you do a save as, or better yet, switch to a quality text editor.

Works now with the "session.auto_start = 0".


Go to topic 40272

Return to index page 364
Return to index page 363
Return to index page 362
Return to index page 361
Return to index page 360
Return to index page 359
Return to index page 358
Return to index page 357
Return to index page 356
Return to index page 355