I've installed Apache2.2.4 & php5.2.3 in my windows xp, evry thing is going perfect but when I want to transfer a session variable to another form its not tranfering.......plz any body help me on this regard. will I have to configer any file....its urgent for me..

Dani AI

Generated

A few quick, practical checks that go beyond "start the session" (good advice from , and ) and the comment from about assigning posted values into session storage.

First, confirm PHP is actually running in those files. If the server sends raw PHP or the short-tag form of PHP is used while short tags are disabled, none of your session code will execute. Use a tiny PHP info page to verify PHP is parsed and to inspect session settings. See PHP’s notes on PHP tags for the exact behavior: PHP short tags and tags documentation.

Next, a short debugging checklist that isolates server vs. script problems:

  • Check the HTTP headers (browser dev tools or curl -I) to see if a Set-Cookie for the session is sent and that the cookie returns on the next request.
  • Verify the session storage folder configured in PHP (session.save_path) exists and is writable by Apache/XAMPP; on Windows that path must be correct and accessible.
  • Look for "headers already sent" warnings in the error log — session initialization must occur before any output.
  • Enable display_errors/error_reporting while debugging so warnings appear.

On XAMPP/Windows specifically: confirm files are served as .php, check Apache/PHP error logs (XAMPP/apache/logs), and watch for antivirus or file-locking that prevents session files being written. If a simple two-page test (one that sets a known value, one that reads it) fails, the root cause is almost certainly server/config (tags, cookie handling, or save_path), not your form markup.

If legacy session functions were being used in examples here, switch to the modern session workflow and test with the diagnostics above. For more on session server-side settings see PHP’s session configuration notes: Session configuration.

Recommended Answers

All 9 Replies

thanx 4 response

try using session_start()

here is a quick example
Session example

try using session_start()

You should put session_start() In each page in the first, and write a variable contains the session... EX:

session_start();
$_SESSION="NAME";
$Variable=$_SESSION;


It's Easy

I have a page that shows job posings and the recordset contains the job title called Position
on my first page I start the session, name the session and give it the value of the recordset like this:

session_start();
$_SESSION= $row_rsposition;


on the next page, I once again start the session and echo it to the screen to test it like so:

session_start();
echo $_SESSION;

you can further assign it to values on the form like this:
(this is a checkbox element)
<input name="Administrative_Support_Assistant" type="checkbox" id="Administrative_Support_Assistant" value="Y" <? if (!$_POST && (!(strcmp($_SESSION, "Administrative Support Assistant")))) { echo "checked=\"checked\"";} ?>/>

for a text box use something like this:
<input name="Position" type="text" id="Position" value=" <? echo $_SESSION;?>"


hope this helps

Now I've installed XAMPP but still facing problem on session:
e.g. file1.php

<?
session_start();
session_register("n");
<body><form action=file2.php method=post>
..........
<input type=text name=n>
<input type=submit value=submit>
</body>
?>

file2.php

<?
session_start();
session_register("n");

print"name=.$n";

?>

the value of "n" is not printing on file2.php ..................if there is anything wrong in this code, plz give me some correct one........

First off, the code you posted is not even valid code. You have php and html mixed in together and no end form tag to boot. Have you even attempted to run this code yourself?

As far as session, you have not set the value of 'n' in the session. In your code, 'n' is a post variable. If you want it in $_SESSION[] you need to set the value yourself. If you only need it the one time, then just read it from $_POST[]. If it needs to persist, set it in $_SESSION[].

It is fairly obvious that you are not reading any of the tutorial links that were posted, but just expecting people to write the code for you. You need to take the time to read and learn from the tutorials and php manual as well.

thanx for the suggestion......i got it.

Are you sure to have session_start(); at the first line of your page

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.