Solved

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

Posted on 2002-05-26
3
174 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks a lot, I was not aware of this change.

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

763 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

13 Experts available now in Live!

Get 1:1 Help Now