Hi,
I having problem to fix this problem. Already search for related thread, but cannot find a solution. The case is like this. I have 2 system that intergrate each other. Let assume as system A and B. User need to login from system A and can use system B if user have authority.

For the session, on 1st page of system B, the value can be display successfully, but having problem when jump to other page. I already declare session_start() on every page. But still not work.

Here the code:
check.php (assign session)

<?
session_start();
$_SESSION['nama']= "";
$_SESSION['id']= "";
$login=$_GET["login"];//value pass from system A
$pwd=$_GET["pwd"];//value pass from system A

$query1="SELECT * FROM login WHERE password='".$login."'";

$result = mysql_query($query1);

while ($row = mysql_fetch_assoc($result)) {
	$_SESSION['nama']= $row['nama'];
	$_SESSION['id']= $row['userid'];
	$_SESSION['cms']= $row['groupcms'];
	header("location:index.php");
	exit;
}

header("location:salah.php");
exit;

mysql_free_result($result);

?>

Having problem when call from sub page that have another sub page. The sub page i had put below code to automatically return to previous page.

print  "<meta http-equiv=\"refresh\" content=\"5;URL=foto_cawangan_cms.php\">";

When return the session value totally blank.Any idea?


Really appreciate your respond and idea. Thanks.

Recommended Answers

All 5 Replies

Hey,
1. Get the session ID in a variable.
2. Pass it along with the url used in headers

header("Location: url?sess=".$sessId)

3. In the header page assign the previous session Id

$sessionID = @$_GET['sess'];
if($sessionID)
session_id($sessionID);

Note: This must be placed before session_start().

pzuurveen and Manuz. thanks for the reply. I will try both suggestion.Thanks again

hi,
i manage to fix this problem by changing

$_SESSION['[B]id[/B]']= $row['userid'];

to other name like this

$_SESSION['[B]ido[/B]']= $row['userid'];

.looks like id word cannot be use.thanks to both pzuurveen and Manuz.

Hey,
You have fixed the issue rit? anyways for ur line ".looks like id word cannot be use."
This indicated that you have used the variable "$_SESSION" in some other related pages.
Mark as Solved if fixed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.