Jump to content

[SOLVED] session problem


janim

Recommended Posts

hi all

i have session called name :

$myname=$_session['name'];

already stored

but why it changes

 

i have page showing books so when i open this page the session changes to the name of the book

why this happens

and this happens just in my server but in localhost everything ok

 

why it would change ?

 

thanx

Link to comment
Share on other sites

sorry phpSensei i can't post all the code it's little big and going between the html code

so it's like that in general :

 

 
<?php
// for the login page :
$name = $_POST['myname'];
$_SESSION['login']=true;
$_SESSION['name']=$name;
?>

 

then i check for lgin or not :

 

<?php 

$check = $_SESSION['name'];
	echo "Welcome back ".$check."<br>";
		echo "<a href=\"profile.php?name={$check}\">My profile</a>";
?>

 

so in my local host it's work good but in my server it's change the session name to the book name in that's page

the book name is comming from mysql like this :

 

<?php
$new=mysql_db_query($b,"select * from $books where id='$id'") or die ("".mysql_error());
if(mysql_num_rows($new)){
$q=mysql_fetch_array($new);
$name=$q[bookname]; 
}
?>

 

so what is the problem ???

why my session name changes to the book name ?

 

 

Link to comment
Share on other sites

The reason why the $_SESSION['name'] is getting changed when $name=$q[bookname]; is executed is because register globals are ON and the $name variable is the same as $_SESSION['name'].

 

You need to use unique variable names when register globals are on. You should also turn off register globals.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.