?
Solved

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

Posted on 2002-05-26
3
Medium Priority
?
180 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
[X]
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
  • 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 400 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…
Suggested Courses

762 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