homepage Welcome to WebmasterWorld Guest from 54.237.95.6
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
[PHP] Sessionproblem
GrodanBoll




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

Hi

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 :)

 

gethan




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

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

$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.

GrodanBoll




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

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

/Grodan

GrodanBoll




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

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 :)

lorax




msg:1279954
 3:42 pm on Apr 3, 2002 (gmt 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.

TIA

GrodanBoll




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

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.

/Grodan

GrodanBoll




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

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. :)

/Grodan

GrodanBoll




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

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 :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved