# PHP session_start () hangs web page. [Un-solved]

## stevler

apache-2.0.54-r11  PHP Version 4.4.0RC1

Can anyone help. 

With any PHP script containing session_start () the script, when run, just hangs. Web page goes blank and stops.

These two little codes do set and read a cookie. 

```
<?php

setcookie("test", "this is a test");

header("Location: readcookie.php");

?> 
```

```
<?php

if($_COOKIE["test"]){

echo "Cookie Found: - " . $_COOKIE["test"] . "<br>";

}else{

echo "No Cookie Found";

}

?>
```

PHP setup snippit.

```
Session Support       enabled

Registered save handlers    files user

session.auto_start      Off   

session.bug_compat_42      On

session.bug_compat_warn      On   

session.cache_expire      180   

session.cache_limiter      nocache   

session.cookie_domain      no value

session.cookie_lifetime      0   

session.cookie_path      /   

session.cookie_secure      Off   

session.entropy_file      no value   

session.entropy_length      0

session.gc_divisor      100   

session.gc_maxlifetime      1440   

session.gc_probability      1   

session.name         PHPSESSID   

session.referer_check      no value   

session.save_handler      files

session.save_path      /tmp   

session.serialize_handler   php

session.use_cookies      On

session.use_only_cookies   Off   

session.use_trans_sid      Off   

```

I've seen a hint in a PHP4 bug report that this may be a known problem. However my Gentoo set up is a new 2.6.11-gentoo-r11  and my previous 2.4 Gentoo had all my PHP scripts running without this problem. I believe my problem is simple and I'm just missing something in my sessions setup..

I've tried to be brief and to the point because I know what its like trauling through long drawn out posts.

Appretiated in advance.Last edited by stevler on Mon Jul 04, 2005 9:24 am; edited 1 time in total

----------

## hanj

Hello

Your code snips don't contain session_start(). Can you verify that the page works fine without session_start call? Also, you mention that the screen goes blank.. do you have error messages turned off in your ini? Are you logging your errors?

hanji

----------

## stevler

Thanks for reply.

Ok. 

The code snips do not contain session_start(). I wanted to show that my sessions were switched on in php and work. 

Any php code that does not contain session_start() is executed and runs with no errors.

If for example I add session_start() to the above code snippets and try to run the code, the browser reports 'Done' and the browser stops as if the page has loaded. See link. [url]removed[/url]

I am logging errors and nothing is reported when any code containing session_start() is run.

I am a website designing hobby'ist and in no way a php programer. I am trying to run other peoples scripts who have kindly made free-source code.

Thanks in advance.Last edited by stevler on Mon Jul 04, 2005 9:25 am; edited 2 times in total

----------

## hanj

Is there anything special in the vhosts file for this domain? I wonder if there are specific php_flags that are getting overwritten in the vhosts flag that is causing this behaviour.

Thanks

hanji

----------

## stevler

I dont think so. I have pretty standard settings in all my virtual hosts.

```
Allow from all

AllowOverride All

Order allow,deny 
```

Its got me thinking about my apache conf files. In previous gentoo installs I did not have this problem. Recently the standard apache2 conf file has changed format from previous.  I have in the past copied and paste a previous known working apache conf so I will have to work through my current set up line by line. Maybe some pointers on where to start would be apreciated.

My apache2 conf file if anyones interested. I dont blame you if your not. [url]removed[/url]

Cheers.

----------

## stevler

Ok. I've been through all my apache2 conf files and found nothing untoward. I am putting this problem down to my gentoo setup. Hopefully when I do a next gentoo install this problem might disapear.

Temp solution:- Do not use any php script containing session_start()

Thanks to all that took an interest and helped out.

----------

## hanj

Hello

What are the permissions on your /tmp dir? Mayb apache/php cannot write sess data in there... and bombs. Do you use openbase_dir or safe_mode, etc?

```
session.save_path      /tmp 
```

HTH

hanji

----------

## hanj

Have you tried to roll back your PHP version? Currently I'm using:  dev-php/mod_php-4.3.11

Here are my php.ini session values:

```
session.save_handler = files

session.use_cookies = 1

session.name = PHPSESSID

session.auto_start = 0

session.cookie_lifetime = 0

session.cookie_path = /

session.cookie_domain =

session.serialize_handler = php

session.gc_probability = 1

session.gc_divisor     = 100

session.gc_maxlifetime = 1440

session.bug_compat_42 = 1

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
```

hanji

----------

