Forum Moderators: coopster
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.
<?php
// logincheck.php - performs validation
// authenticate using form variables
// check login and password
// connect and execute query
include("includes/config.inc.php");
$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!!";
exit();
}
// if row exists -> user/password combination is correct
else
{
// initiate a session
session_start();// 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']);
exit();
}
?>
Some of the comments is i swedish but I hope that you will understand it anyway :)
/Grodan :)
$varname = 'value';
session_register('varname');
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.
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...
/Grodan
How do i set the rights för external webusers on a Win 2000 server?
/Grodan :)
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.
/Grodan
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. :)
/Grodan
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 :)