Page 1 of 1

after post other page, can't get session

Posted: Fri Jun 20, 2003 6:15 am
by valen53
i thought define session was same as set cookies.

unfortunatelly after i define session, i can get the session variable on same page, but after post to other page, it can't get back the sesson variable.

anyone can help me ???
4 posting session variable to another page but still can get the variable like cookie.

Posted: Fri Jun 20, 2003 6:19 am
by m@ndio
can I see your code?

Posted: Fri Jun 20, 2003 7:16 am
by twigletmac
Do you have session_start() on all pages which you try and access session variables on? It really helps us help you if you post some of the code you are trying to use.

Mac

Posted: Fri Jun 20, 2003 7:43 am
by rashed
Write in the begining of every page, I have used only session_start(); but sometimes it gives errors, Its my thinking.
if(isset($_REQUEST[session_name()]))session_start();

Posted: Sun Jun 22, 2003 8:55 pm
by valen53
thank to all..
after i add session_start() for each page, it was can be function already.

But the PC didn't accept cookie 1, and didn't accept session also. i just so blur for it. Other PCs was work correctly.
The sample coding ....
session.php

Code: Select all

<?php
 session_start(); 
session_register('username') ;
?>
<html>
<body>
<?php 

if (isset($posted))
  $username = $posted ;
  if (isset($username))
  &#123;
    print("<P>we know u are $username ") ;
	&#125;
	else
	   print("<P>we know u are $username ") ;
?>	
<form action = "session.php" name="form1" method="post" >
  <p> 
    <input type="text" name="posted">
  </p>
  <p> 
    <input type="submit" name="Submit" value="Submit">
    <a href="session1.php">to session1 </a></p>
</form>
</body>
</html>
session1.php

Code: Select all

<?
   session_start(); 
?>
<html>
<body>
<?php 

  if (isset($username))
  &#123;
    print("<P>we know u are $username ") ;
	&#125;
?>
<a href="session.php">go back</a> 
</body>
</html>

Posted: Mon Jun 23, 2003 4:00 am
by twigletmac
That code relies on register_globals being on - could that be the problem?

Have you had a look at:
Before Post Read: Sessions with a Minor in User Logins

Mac

Posted: Mon Jun 23, 2003 9:30 pm
by valen53
thankx reply .. and ur guideline also..

the url u give, i read through already and try the sample also.

Before Post Read: Sessions with a Minor in User Logins

But the PC can't accept cookie 1, still can not function in local server. But function in the devnetwork.net/session/

i think maybe is my domain problem. b'cos when using IP such as
192.168.0.66/page1.php, it was function but use domain such as
valen_server/page1.php, it still can not function.

is it the php.ini or apache setting problem ? anything i need to changing?

register_globals was on already.