473,394 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

$_SESSION variable not carrying

Greetings,
I am trying to do some simple session stuff. However it does not seem
as though the session variable is being created for my site. I am
running the latest version of PHP and apache that I installed as part
of WAMP. Machine is XP SP2.

Basically I am trying to do something simple such as:

<?php

// initialize a session
session_start();

// increment a session counter
$_SESSION['counter']++;

// print value
echo "You have viewed this page " . $_SESSION['counter'] . " times";

?>

However my counter does not increment. I can also not see where any
sort of cookie has been created within IE, although firefox shows the
following:

Name: PHPSESSID
Content: 4s0n98f1s7jea6kg11psi4ckd3
Host: 10.0.0.15
Path: /
Send for: Any type of connection
Expires: at end of session

I am not sure about the Path: variable though. The address for my site
is 10.0.0.15/recipe

physical is C:\wamp\www\recipe

Here are some of the contents of my php.ini file:

[Session]
session.save_handler = files

session.save_path = "C:\Windows\temp "

session.use_cookies = 1

session.name = PHPSESSID

session.auto_start = 0

session.cookie_lifetime = 0

session.cookie_path = /

session.cookie_domain =

Any suggestions would be greatly appreciated!

Jul 18 '07 #1
4 2329
"dp*****@gmail.com" <dp*****@gmail.comwrote in
news:11*********************@x35g2000prf.googlegro ups.com:
Greetings,
I am trying to do some simple session stuff. However it does not seem
as though the session variable is being created for my site. I am
running the latest version of PHP and apache that I installed as part
of WAMP. Machine is XP SP2.

Basically I am trying to do something simple such as:

<?php

// initialize a session
session_start();

// increment a session counter
$_SESSION['counter']++;

// print value
echo "You have viewed this page " . $_SESSION['counter'] . " times";
you don't see your new session/cookie value until you call it from the
NEXT/FOLLOWING page.

Also, this might make more sense:
$_SESSION['counter'] = $_SESSION['counter']++;
Jul 18 '07 #2
Good Man wrote:
"dp*****@gmail.com" <dp*****@gmail.comwrote in
news:11*********************@x35g2000prf.googlegro ups.com:
>Greetings,
I am trying to do some simple session stuff. However it does not seem
as though the session variable is being created for my site. I am
running the latest version of PHP and apache that I installed as part
of WAMP. Machine is XP SP2.

Basically I am trying to do something simple such as:

<?php

// initialize a session
session_start();

// increment a session counter
$_SESSION['counter']++;
First of all, never use uninitialized variables. Even if you think
this is o.k. if(!isset($_SESSION['counter'])) $_SESSION['counter']=0; is
not hard code but now you don't depend of session vars behavior modified
with every PHP version.
>// print value
echo "You have viewed this page " . $_SESSION['counter'] . " times";

you don't see your new session/cookie value until you call it from the
NEXT/FOLLOWING page.

Also, this might make more sense:
$_SESSION['counter'] = $_SESSION['counter']++;
Will never increment it because of post-increment.

I think you mean this:
$_SESSION['counter'] = $_SESSION['counter']+1;
Jul 19 '07 #3
Alexey Kulentsov wrote:
Good Man wrote:
>"dp*****@gmail.com" <dp*****@gmail.comwrote in
news:11*********************@x35g2000prf.googlegr oups.com:
>>Greetings,
I am trying to do some simple session stuff. However it does not seem
as though the session variable is being created for my site. I am
running the latest version of PHP and apache that I installed as part
of WAMP. Machine is XP SP2.

Basically I am trying to do something simple such as:

<?php

// initialize a session
session_start();

// increment a session counter
$_SESSION['counter']++;

First of all, never use uninitialized variables. Even if you think this
is o.k. if(!isset($_SESSION['counter'])) $_SESSION['counter']=0; is not
hard code but now you don't depend of session vars behavior modified
with every PHP version.
>>// print value
echo "You have viewed this page " . $_SESSION['counter'] . " times";

you don't see your new session/cookie value until you call it from the
NEXT/FOLLOWING page.

Also, this might make more sense:
$_SESSION['counter'] = $_SESSION['counter']++;
Will never increment it because of post-increment.

I think you mean this:
$_SESSION['counter'] = $_SESSION['counter']+1;
Or, just

$_SESSION['counter']++;

$_SESSION['counter'] = $_SESSION['counter']++;

is an "undefined operation" - it could contain the old value or the new
value. Either result could be considered "legal".

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 19 '07 #4
dp*****@gmail.com wrote:
session.save_path = "C:\Windows\temp "
Is that space character inside the path really there? If so, remove it.

Also, try using "/" instead of "\" in the path -- backslashes are used in
PHP strings to escape special characters. In particular, your path
contains "\t" which PHP may treat as a tab character!

Lastly, if you're using NTFS (you don't specify) check which user Apache is
running as, and make sure that the Temp folder is writable by that user.
To be sure, you could try giving "Full Control" on the Temp folder to
"Everyone". (I think that's the terminology used in XP.)

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 29 days, 15:47.]

Parsing an HTML Table with PEAR's XML_HTTPSax3
http://tobyinkster.co.uk/blog/2007/0...table-parsing/
Jul 20 '07 #5

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

Similar topics

0
by: Thomas Carcaud | last post by:
I read php manual many times but I can't figure out register_globals works. I m using Php 4.3.2 and register_globals on. It seems to have different effects on $_GET and $_SESSION. First with $_GET...
5
by: Ken | last post by:
What am I doing wrong? I set the variable co_name on the first page with an <input.... > and session_start() at the top of both pages. Clicking on a link that takes me to the second page: ...
3
by: Phil Powell | last post by:
PHP: unset($_SESSION); In my original environment (PHP 4.3.2) this line will delete the session variable 'mainDisplay'. But in the testing environment (PHP 4.3.6) the variable persists even...
4
by: comp.lang.php | last post by:
This is an urgent request (as always) generate_admin_customer_position_dropdown($customerResult, $customerResult->id); print_r($_SESSION); This code will generate an HTML dropdown as...
12
by: Michael Windsor | last post by:
I've been trying to integrate some PHP pages of my own with some existing code. The details of this are for the support forums for that code (where I have been asking questions), but I wonder if...
15
by: Evil Otto | last post by:
My page loads, and calls an init() function that returns content to a div on the page, as well as setting a $_SESSION variable. The content it returns includes a link that calls the same variable,...
1
by: bsprogs | last post by:
I am currnetly programming a file hosting website in PHP and I am slowly integrating AJAX into the website. Here is my problem: The user uploads the file. The server processes the file and...
2
by: sharonDonnelly | last post by:
Hi Really dumb problem that's got me beat. Can someone help. The prolem: I'm trying to count the number of times an item has been clicked. There are many items. I want to create a session...
4
TheServant
by: TheServant | last post by:
Hi guys, This is my situation. I have 3 sets of data used on every page of my website. Two of these never change, and the reason they are stored in MySQL and recalled into the $_SESSION variable is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.