This topic is locked

Bypassing login but using functionality of login

3/17/2006 5:23:57 AM
PHPRunner General questions
Pfeiffer author

Hello,

seems to be a little bit strange but I will explain.
I need the functionality of login to control user actions (update,delete..).

But I need not the login mask because the user is calling PHPRunner from another application

which will already set a cookie before PHPRunner-Application starts.

So if the cookie is there user access is allowed.
So I made the following changes
--------------------------------------------

function LoginOnLoad()

{

//** Custom code ****

// put your custom code here
$_SESSION["UserID"] = $_COOKIE["gemseuser"];

$_SESSION["AccessLevel"] = "User";

$_SESSION["OwnerID"] = $_SESSION["UserID"]
if($_SESSION["UserID"])

header("Location: menu.php");
}
UserID is correctly set by COOKIE gemesuser.

So menu.php is correctly called immediately.
---------File menu.php -------------------

<?php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

session_start();

set_magic_quotes_runtime(0);
include("include/dbcommon.php");
if(!@$_SESSION["UserID"])

{

header("Location: login.php");

return;

}
But here unexpectedly $_SESSION["UserID"] is not defined any longer, so I'm redirected to login...

A neverending loop.
Where the value of $_SESSION["UserID"] is destroyed and how can I prevent this ?

Do I have to define other $_Session-Variables ???
Best regards

Uwe

Admin 3/20/2006

Uwe,
you can try to change following:

if($_SESSION["UserID"])

header("Location: menu.php");

exit();

D
drh 3/21/2006

Hi. I am new to php and phprunner. This is exactly what I need to do. So I generated the events.php script as follows:

<?php^M

function LoginOnLoad()

{^M

$_SESSION["UserID"] = $_COOKIE["PHPSESSID"];^M

$_SESSION["AccessLevel"] = "User";^M

$_SESSION["OwnerID"] = $_SESSION["UserID"];^M

^M

print $_COOKIE["PHPSESSID"];
if($_SESSION["UserID"]){^M

header("Location: menu.php");^M

exit;^M

}

}^M

^M

^M

?>
and menu.php file like such:

<?php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

session_start();

set_magic_quotes_runtime(0);
include("include/dbcommon.php");
print "@$_SESSION["UserID"]";
if(!@$_SESSION["UserID"])

{

header("Location: login.php");

return;

}

?>
However, when I run the script, I get the following errors:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/dave.local.solution-group.com/httpdocs/include/events.php:8'>dave.local.solution-group.com/httpdocs/include/events.php:8) in /var/www/vhosts/dave.local.solution-group.com/httpdocs/include/events.php on line 11
Can anyone tell me whats wrong.
Did this work for you Uwe?
Thanks in advance.
Dave

Pfeiffer author 3/22/2006

Uwe,

you can try to change following:


Hello Sergey,

it makes no difference wether I use

if(!@$_SESSION["UserID"]) or if(!$_SESSION["UserID"])

The session UserID gets lost.
This must happen between line (menu.php)
ini_set("display_errors","1");

ini_set("display_startup_errors","1");

session_start();

set_magic_quotes_runtime(0);
include("include/dbcommon.php");
if(!@$_SESSION["UserID"])
Best regards Uwe
Hello Dave,
I think you may not use the print commands...

But whatever, you tried exactly what I want to do.

It will not work...
I posted my reply to Sergey.

Let's see what will happen.
Best regards Uwe

Hi. I am new to php and phprunner. This is exactly what I need to do. So I generated the events.php script as follows:

<?php^M

function LoginOnLoad()

{^M

$_SESSION["UserID"] = $_COOKIE["PHPSESSID"];^M

$_SESSION["AccessLevel"] = "User";^M

$_SESSION["OwnerID"] = $_SESSION["UserID"];^M

^M

print $_COOKIE["PHPSESSID"];
if($_SESSION["UserID"]){^M

header("Location: menu.php");^M

exit;^M

}

}^M

^M

^M

?>
and menu.php file like such:

<?php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

session_start();

set_magic_quotes_runtime(0);
include("include/dbcommon.php");
print "@$_SESSION["UserID"]";
if(!@$_SESSION["UserID"])

{

header("Location: login.php");

return;

}

?>
However, when I run the script, I get the following errors:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/dave.local.solution-group.com/httpdocs/include/events.php:8'>dave.local.solution-group.com/httpdocs/include/events.php:8) in /var/www/vhosts/dave.local.solution-group.com/httpdocs/include/events.php on line 11
Can anyone tell me whats wrong.
Did this work for you Uwe?
Thanks in advance.
Dave

Admin 3/22/2006

Uwe,
please ensure that your LoginOnLoad function looks like:

function LoginOnLoad()

{

$_SESSION["UserID"] = $_COOKIE["gemseuser"];

$_SESSION["AccessLevel"] = "User";

$_SESSION["OwnerID"] = $_SESSION["UserID"]
if($_SESSION["UserID"])

header("Location: menu.php");

exit();

}

Admin 3/22/2006

Dale,
to make your pages working delete

print $_COOKIE["PHPSESSID"];

and

print "@$_SESSION["UserID"]";.