Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

[PHP] Sessionproblem



11:02 am on Apr 3, 2002 (gmt 0)

Inactive Member
Account Expired



I have some trouble with my sessions. My server have win 2000 server, Apache 1.3.23 and PHP 4.1.2.

The server creates the sessionfiles as i should, but the files are not filled with the sessionsvesriables that I have defiened.

I have developed yhe files on another machine and it works fine there.

Can someone plz help me?

Below is the code for the file that registrers teh sessions.

// logincheck.php - performs validation
// authenticate using form variables
// check login and password
// connect and execute query
$sqlquery = "SELECT persId from tblPerson WHERE persAnvnamn = '".$_REQUEST['user']."' AND persLosenord = '".$_REQUEST['password']."'";
$result = mssql_query($sqlquery,$dbconn) or die ("Error in query: $sqlquery.");
// user/pass combination is wrong
if (mssql_num_rows($result) != 1)
//header ("Location: error.php?id=1");
echo "Fel fel fel fel!!";
// if row exists -> user/password combination is correct
// initiate a session

// register some session variables
// registrerar persId
list($persId) = mssql_fetch_row($result);
$_SESSION['session_persId'] = $persId;
mssql_free_result ($result);
// registrerar personens behörighet
$sqlquery = "SELECT avdId, rattighetId from tblRattighet WHERE persId = '".$_SESSION['session_persId']."'";
$result = mssql_query($sqlquery,$dbconn) or die ("Error in query: $sqlquery.");
$strangen = "";
while ($row = mssql_fetch_array ($result)) // lägger in behörigheterna i en sträng
$strangen.= ".".$row["avdId"].":".$row["rattighetId"];
$strangen .= "."; // ser till så att strängen avslutas med en '.' oxå
$_SESSION['session_rattighet'] = $strangen;
mssql_free_result ($result);

// redirect to protected page
header ("Location: ".$_REQUEST['url']);

Some of the comments is i swedish but I hope that you will understand it anyway :)

/Grodan :)

1:03 pm on Apr 3, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 8, 2001
votes: 0

Just a quick check Grodan - do you have the same problem when using

$varname = 'value';

as opposed to

$_SESSION['varname'] = 'value';

I've only used the former and would be supsicious of the latter method as the under score signifies that its a private variable and should be accessed via some other method.


2:21 pm on Apr 3, 2002 (gmt 0)

Inactive Member
Account Expired


Hi gethan

I have used the session_registrer before and that works.
But I will set the globals to 'off' in php.ini and according to the manual should you use $_SESSION instead now.

And $_SESSION works om my developmentmachine which looks almost the same as the server.

The only problem is that the server don't put the sessionvalues into the sessionfile...



3:19 pm on Apr 3, 2002 (gmt 0)

Inactive Member
Account Expired


Hmm, it seems like the user in the webpage dont have the rights to write in the sessionfiles... could that be true?
When I'm developing it works but then I'm accessing the pages fron 'localhost', maybe I have the right rights then?

How do i set the rights för external webusers on a Win 2000 server?

/Grodan :)

3:42 pm on Apr 3, 2002 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Mar 31, 2002
votes: 0

Hey GrodonBall,
I just wanted to confirm that according to what you read session_register() has been replaced by $_SESSION() = value.

And where in the manual did you see this - so I can read up on it.



4:04 pm on Apr 3, 2002 (gmt 0)

Inactive Member
Account Expired


Hi lorax

It is not replaced, but it is recommended that you use $_SESSION instead.

Search for 'session' in the PHP manual.
Sorry if you missunderstod me.



9:07 am on Apr 4, 2002 (gmt 0)

Inactive Member
Account Expired


Hmm, does anyone know if I use the $_SESSION-way to register sessionvariables and have globalvaribles set to 'On' in php.ini, does it still work?

I have only tried with globalvariabels set to 'Off' and that works.

I can't try it myself at the moment, but i'd like to know so I can keep on planning. :)



1:19 pm on Apr 4, 2002 (gmt 0)

Inactive Member
Account Expired


I created the IUSER_computername. Then I gave rights to that user in the libary that contains the sessionfiles.

That solved the problem on my developmentcomputer which have FAT32 as filesystem. Then I copied over all the files to the webserver and did the same thing (IUSER_) on that machine. But there it doesn't work :(

The only difference is that the webserver have NTFS as a filesystem.

Can anyone help me and solve the problem?

I would jump high in joy :)

/Grodan :)


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members