473,840 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sessions not Working on WAMP

Hey

I have a WAMP setup (windows/apache/mysql/php). I'm running the latest
version of all of them with a default installation of all of them. PHP
works great with apache (as a module, not cgi), except that sessions
aren't working. The script at the bottom of this post never increments
my hit count. Do I need to turn sessions on somehow in php.ini?

Thanks,

PulsarSL

----

Works great on a remote web server I have, so it's not the script...

----

<?php
// Initialize a session. This call either creates
// a new session or re-establishes an existing one.
session_start( );

// If this is a new session, then the variable
// $count will not be registered
if (!session_is_re gistered("count "))
{
session_registe r("count");
session_registe r("start");

$count = 0;
$start = time( );
}
else
{
$count++;
}

$sessionId = session_id( );

?>
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd" >
<html>
<head><title>Se ssions</title></head>
<body>
<p>This page points at a session
(<?=$sessionId? >)
<br>count = <?=$count?>.
<br>start = <?=$start?>.
<p>This session has lasted
<?php
$duration = time( ) - $start;
echo "$duration" ;
?>
seconds.
</body>
</html>

----

Dec 24 '05 #1
2 17178
vdP
Pu******@gmail. com wrote:
Hey

I have a WAMP setup (windows/apache/mysql/php). I'm running the latest
version of all of them with a default installation of all of them. PHP
works great with apache (as a module, not cgi), except that sessions
aren't working. The script at the bottom of this post never increments
my hit count. Do I need to turn sessions on somehow in php.ini?

Thanks,

PulsarSL ----

Works great on a remote web server I have, so it's not the script...

<?php
// Initialize a session. This call either creates
// a new session or re-establishes an existing one.
session_start( );

// If this is a new session, then the variable
// $count will not be registered
if (!session_is_re gistered("count "))
{
session_registe r("count");
session_registe r("start");

$count = 0;
$start = time( );
}


If you use the latest version of WAMP or PHP, you are using PHP 5. This
means that register_global s is disabled by default. Therefore you should
use the superglobal $_SESSION, instead of session_is_regi stered and
session_registe r. Quoting the manual-page of session_registe r at php.net
( http://nl3.php.net/manual/en/functio...n-register.php)
"If you want your script to work regardless of register_global s, you
need to instead use the $_SESSION array as $_SESSION entries are
automatically registered. If your script uses session_registe r(), it
will not work in environments where the PHP directive register_global s
is disabled."

Using $_SESSION the code can be rewritten as (may contain typos)
if (!isset($_SESSI ON['count'])){
$_SESSION['count']=0;
$_SESSION['start']=time();
} else {
$_SESSION['count']++;
}

Hope this helps.

vdP
Dec 24 '05 #2

Hope this helps.


Yes, thank you.

PulsarSL

Dec 24 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
7206
by: Chewy509 | last post by:
Hi Everyone, I'll just start, and say I am not a PHP developer (I'm a sysadmin, who has gotten lumped with a non-working website). But since I like to do this type of stuff, I though I might just learn WTF is going on? :) Basically, sessions are being created, but no info in being stored in the session, and if data is stored (about 1 in 20 goes), it doesn't follow-on on a page redirect.
7
7548
by: John | last post by:
Hello. I want to get this blasted .htaccess file sorted out, so I can have sessions without register_globals being on. I have looked everywhere for info on this and I mean everywhere including the php.net manual. In the manual it said to include something like the following:
3
3724
by: Will Woodhull | last post by:
Hi, I'm new here-- I've been reading the group for a couple of days. Nice group; I like the way n00b33 questions are handled. I've been using a Javascript routine in index.html to determine a visitor's browser's capabilities. The Javascript then calls main.php, passing back its findings with a GET string; main.php saves the data as a visitor's profile in $_SESSION elements. It then serves up home.html and any further pages requested...
2
6913
by: Yogee | last post by:
Hello all, I dont know the exact group where I should post my questions. So, I m doing it on most of the groups which support components of LAMP stack. My client wants to use WAMP ( Windows + apache + MySQL + PHP ). But the site performance is very slow on windows. I dont know the exact reasons. I have seen some benchmark details on internet. But still they are not
1
5214
by: Duncan | last post by:
I have a strange problem with sessions in PHP 5. I have a simple script that prints a random number both as a string and a picture on the screen. When I run the script for the first time, it works perfectly. However, when I refresh the page, new updated random number does not propagate to the image displayer script through sessions. The image displayer script continues showing the old number instead of the new random number. I checked the...
4
4677
by: Gaurav Agarwal | last post by:
Hi, Am using WAMP5 and python 2.4.3. I tried to install mod_python 3.2.5 for python2.4. When i tried starting wamp, Firstly there was no error message in the apache error log. I saw error message in windows event viewer : "The Apache service named Apache.exe reported the following error: before the error.log file could be opened.
1
4335
by: fatalparadox | last post by:
I had WAMP Server installed for a few months, everything was fine. Now all of a sudden it stopped working. It still executes the PHP but it doesn't allow me to write to a .txt file anymore. When I put the same files on the web it works great. And it worked with wamp server before yesterday. So I uninstalled WAMP server and installed WAMP Server2 and it still has the same issues.
2
6211
by: eihabisaac | last post by:
hey everyone i just installed WAMP on my vista and i think everything worked well but when i go to the localhost it tell me that there is an error. so i installed it on an XP and it worked perfectly ,,what is the problem with vista and wamp can any body help.. by the way i turned off the firewall
12
1601
by: Angkor | last post by:
Hi All, I am trying to pass value from a page to another page through session variable. session_start(); $_SESSION = $value("aid"); ..... $_SESSION has value within its original page. But
0
9861
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10301
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9444
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7023
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5685
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3139
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.