Page 1 of 2

Session variable

Posted: Tue Feb 10, 2004 7:54 am
by no1shah
Hello Friends,
I had created session variables in the web application using php,the application is running well in local host, but once it is uploaded on net the session variable does not not create or if creating then it is not accessible.
If u have any suggestion plz. help me

Posted: Tue Feb 10, 2004 8:59 am
by twigletmac
Versions of PHP on local and host? Code?

Mac

Session Variable problem

Posted: Wed Feb 11, 2004 1:49 am
by no1shah
I am using version 4.3.4 at local host and server is using 4.3.2,There is difference in the php.ini of both (in session.save_path);
Kindly suggest how this problem will be sorted out

Re: Session Variable problem

Posted: Wed Feb 11, 2004 3:19 am
by JayBird
no1shah wrote:There is difference in the php.ini of both (in session.save_path);
That should matter.

Can you show us your code.

Mark

Posted: Wed Feb 11, 2004 3:47 am
by no1shah
Thanks for giving your precious time
in the first page i had created the session variable,
$_SESSION['email']=$_POST['email'];
$_SESSION['password']=$_POST['password'];
$sql = "SELECT id, first_name, last_name FROM members WHERE email='$_POST[email]'";
$result = mysql_query($sql)
or die ("Could not retrieve data!");
$IDtag = mysql_fetch_row($result);
//VALUE ASSIGNED TO $_SESSION
$_SESSION['IDtag']=$IDtag;
and on the second page i am echoing this $_SESSION['IDtag']
but this is not working on the isp server,
while it is running correctly on the local host.
can you suggest me that how to set the session_save_path() on the server,or if version 4.3.2 of php is supporting the session,actually the problem begins when we found that register_global of ISP is OFF while we had coded according to ON ,so we had made all the changes on the code and after uploading the site we are getting the problem,that sessin variable is not passing the value to other page,If you can then plz. sort out this problem.
Thanks for reading this boaring mail,but if u have any suggestion the n plz. f/w it to forum,

Posted: Wed Feb 11, 2004 4:11 am
by JayBird
where is your session_start()?

Mark

session variable

Posted: Wed Feb 11, 2004 4:19 am
by no1shah
well it won't start in the 1st page but in the begining of 2nd page it starts,
this code is running well in the php version 4.3.4 but not in 4.3.2 which is of ISP.
Plz. suggest me some thing which i could implement

Posted: Wed Feb 11, 2004 4:41 am
by JayBird
you need to use session_start() on all pages where you are using session variables.

Can you show us the FULL code for the two page.

Please put [syntax=php][/syntax] tage around your code when posting so that it is easier for us to read.

Mark

Session Variable

Posted: Wed Feb 11, 2004 5:27 am
by no1shah
Hello Sir,
actually the code is quite long i am sending you the prototype of the problem, plz. suggest me the solution
i am sending the code of the two pages
Code of the first page:
<?php
$i="hello";
$_SESSION['test']=$i;
?>
Code of the second page:
<?php
session_start();
echo $_SESSION['test'];
?>

Registers_global of php.ini is OFF and it is our requirement.
Plz suggest me what changes are necessary to run this code in the php version 4.3.2 rather then 4.3.4

Posted: Wed Feb 11, 2004 5:31 am
by JayBird
you can't set a session variable, without first starting the session.

Page 1

Code: Select all

<?php 
session_start(); // Need this first on all pages where using session variables
$i="hello"; 
$_SESSION['test']=$i; 
?>
Page 2

Code: Select all

<?php 
session_start(); 
echo $_SESSION['test']; 
?>
Mark

Posted: Wed Feb 11, 2004 5:42 am
by no1shah
Thanks but still i am getting problem??? :?:

Posted: Wed Feb 11, 2004 5:55 am
by twigletmac
Have you tried the sessions using two very simple pages to see if that works? If not try these:

page1.php

Code: Select all

<?php 
session_start();
$_SESSION['test'] = 'foo';
echo '<pre>';
print_r($_SESSION);
echo '</pre>';
?>
<p><a href="page2.php">Page 2</a></p>
page2.php

Code: Select all

<?php
session_start();
echo '<pre>';
print_r($_SESSION);
echo '</pre>';
?>
Do you get the same output on each page?

Mac

Session variable

Posted: Wed Feb 11, 2004 10:33 pm
by no1shah
HEllo Friends
Thanks for ur suggestions, i think i am near to solution,what i found that there is change in the session.save_path of both versions,so it needed to set the path where to store session variable,so before starting session it requires to set the path ,this is working on the local host but not the problem comes at the ISp sere\ver i donot know how and where to store the session there,i had tried to store the session at server my making a folder at server but still it is not working,i u can suggest me that how and where to set the path at server to store the sesion variable.
Looking f/w for solution today
Divyesh

Session Problem

Posted: Thu Feb 12, 2004 1:10 am
by no1shah
Well i had checked the php.ini file of isp,of version 4.3.2 in which by default value of session.save_path is c:\php\sessiondata and they had changed the value of this variable to ".\" so the session are storing on the root of the site.
Is there be any solution of this problem.
Looking f/w for solution today
Divyesh

IS There is no one to solve this problem

Posted: Thu Feb 12, 2004 5:29 am
by no1shah
Dear Friends
Are u not finding the solution of my prob