Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2002-05-26
3
177 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

860 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