sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
junior
Forum Newbie
Posts: 4
Joined: Wed Aug 03, 2005 6:21 am

sessions

Post by junior »

Hi
I'm new to this forum so sorry if this post should be in a different disscussion.

I am having problems using sessions in php. The code i have written works on one host but on another it does'nt work!!!

the code is:

<?php
session_start();
$_SESSION['sess_var'] = "Hello world!";

echo 'The content of $_SESSION[\'sess_var\'] is ' .$_SESSION['sess_var'].'<br />';

?>

both servers are running PHP 4.4.0

Thanks

junior
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You should post it in the code section.

You can prepend the following to your code:

Code: Select all

ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);
I have a feeling that on one server there will be an error that session could not write to file...
imstupid
Forum Commoner
Posts: 84
Joined: Fri Feb 18, 2005 1:24 pm

Post by imstupid »

hey-
i'm having the exact same problem. tim- what's the next step... I've got the "session could not write to file" error message, and

Code: Select all

print_r($_SESSION );
gives me Array()

thanks as always

man this combination of pollution and humidity is giving me headaches.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

This question has been asked many times before, so if you use the search button, copy the error message (remove the specified parts about your file) you should find the solutions pretty easily...


(Make sure the session.save_path exists, and that the users that is running php (typically www-data/nobody) has sufficient access rights...)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

moved to PHP - Code.. :roll:
junior
Forum Newbie
Posts: 4
Joined: Wed Aug 03, 2005 6:21 am

Post by junior »

Tim

I did that and got

Fatal error: Call to undefined function: session_start() ...file path

Thanks

Aouse
junior
Forum Newbie
Posts: 4
Joined: Wed Aug 03, 2005 6:21 am

Post by junior »

Ok

I've been told i need to enable 'session support'

Any one know how to do that?

Thanks

Junior
junior
Forum Newbie
Posts: 4
Joined: Wed Aug 03, 2005 6:21 am

Post by junior »

Ok

My web hoster managed to enable sessions in the php installation

Thanks guys

Junior
Post Reply