[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2002-05-26
3
Medium Priority
?
181 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

656 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