Solved

Session not working with PHP 4.21 / Apache 1.26 under Windows XP

Posted on 2002-05-26
3
176 Views
Last Modified: 2008-03-17
Hi,

My session management is not working properly,

I have tried the following very basic script

<?php

session_start();
session_register("counter");
print($counter);
$counter++;

?>

It should increment the number displayed each time I click in reload ( it works fine with PHP 4.0.5, Apache 1.3.19 under Win 2k (Php is used as module in both cases)

The session file is created and looks OK, but The session_start() does not seem to work.

Can anybody help me, I cannot fix this issue and I am pretty convinced that the php and Apache configuration files are OK.

Thanks,

Marcel
0
Comment
Question by:MFrey
  • 2
3 Comments
 
LVL 5

Expert Comment

by:dkjariwala
ID: 7035705
As you would be aware that from PHP version 4.2.1, variables are not registerd in global scope automatically.

So you might like to try,


<?php

session_start();
$counter = $HTTP_SESSION_VARS['counter'];
print $counter;
$HTTP_SESSION_VARS['counter']++;

?>

or

<?php

session_start();
$counter = $_SESSION['counter'];
print $counter;
$_SESSION['counter']++;

?>

That works.
Read release notes at http://www.php.net/release_4_2_1.php

You can even

JD
0
 
LVL 5

Accepted Solution

by:
dkjariwala earned 100 total points
ID: 7035709
Read session_register notes at http://www.php.net/manual/en/function.session-register.php.

As register_globas are OFF by default you need to change your code a bit.

JD
0
 

Author Comment

by:MFrey
ID: 7035723
Thanks a lot, I was not aware of this change.

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now