470,833 Members | 1,576 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

Problem using $_SESSION

Hello all,

I wondered if anyone could offer me some guidance, I wrote this script
using the dzsoft php editor, which links to php.exe and a internal
server.

Though when I run the code the session files are created, but the item
number in the files never increase beyond (0).

I just wondered if there was anyone options in the php.ini I could
change, to allow this premission. Or any session option I could add to
the code.

Many thanks

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

session_save_path('c:\\');
session_start();
if (!isset($_SESSION['item1'])) $_SESSION['item1'] = 0;
if (!isset($_SESSION['item2'])) $_SESSION['item2'] = 0;

if(isset($_GET['Item1'])){
$_SESSION['item1']++;
}
if(isset($_GET['Item2'])){
$_SESSION['item2']++;
}
?>

<html>
<head>
<title>Test Page</title>
</head>

<body>

<form>
<input type="submit" name="Item1" value="Item 1">
<input type="submit" name="Item2" value="Item 2">

<p>Number of Item 1 clicks: <?php echo $_SESSION['item1']; ?></p>
<p>Number of Item 2 clicks: <?php echo $_SESSION['item2']; ?></p>
</form>

</body>
</html>
Jul 17 '05 #1
6 4419
"Antoni" <An***********@aol.com> wrote in message
news:93**************************@posting.google.c om...
Hello all,

I wondered if anyone could offer me some guidance, I wrote this script
using the dzsoft php editor, which links to php.exe and a internal
server.

Though when I run the code the session files are created, but the item
number in the files never increase beyond (0).

I just wondered if there was anyone options in the php.ini I could
change, to allow this premission. Or any session option I could add to
the code.

Many thanks

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

session_save_path('c:\\');


Here, you set the session save path, but what are the rest of your session
settings in the php.ini file? Using cookies? Rewriting? Did your URL get
rewritten on the first submission?

Come to think of it... and I haven't tested... the initial URL re-writing
(necessary until it is determined whether the cookie (if used) will be
accepted) might not occur if you have no action parameter on your form tag.
I haven't ever coded that way and haven't tried it.

- Virgil
Jul 17 '05 #2
> Though when I run the code the session files are created, but the item
number in the files never increase beyond (0).


Well, from the code you provided, I can tell you that there is no problem
with the code. Whatever is happening is caused by some configuration issues.

Things to check in php.ini

session.auto_start
session.use_cookies
session.use_only_cookies
session.use_trans_sid
session.referer_check (this can be tough to track down but is a lot of times
a problem)

Aside from that, you may need to check your browser settings and see if your
security is too high..

____________________________________
Wil Moore III, MCP | Integrations Specialist |
Assistant Webmaster Realnet Software | Homecomps.com
Jul 17 '05 #3
In article <93**************************@posting.google.com >, Antoni wrote:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

session_save_path('c:\\');


Try it with session_save_path('C:/'); or 'C:\' or "C:\\"
--
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php>
Jul 17 '05 #4
"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2i************@uni-berlin.de...
Try it with session_save_path('C:/'); or 'C:\' or "C:\\"


C:\Temp or some other temporary directory would be better place.
Jul 17 '05 #5
Antoni wrote:
(snip)
<body>

<form>


As Virgil said, try

<form action="<?php echo $_SERVER['PHP_SELF']; ?>">

instead of your plain "<form>"

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #6
Hello!
I have the following:
Apache/2.0.49 (Debian GNU/Linux) PHP/4.3.4 Server at xxx Port 80
from apache2-mpm-prefork debian package, the newest available

I've been messing with it for quite long and none of those details in
the prior posts matter or at least You know they matter right away,
when the error reporting is on. I have a friend with:
Apache/1.3.31 and php4 on Gentoo
and the scripts I have written are working there. I've been checking
my php.ini with his one and there were some minor differences, I set
those up to his values and restarted, but it still doesn't work. I
have no session at all. No variables are defined, not even session
constant PHPSESSID has a value.

So my question is, what security configuration in server may cause
this kind of behaviour?

P.S. It's urgent

Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by M.D. | last post: by
9 posts views Thread by Bartosz Wegrzyn | last post: by
5 posts views Thread by Ken | last post: by
7 posts views Thread by Nicole | last post: by
4 posts views Thread by Ian Davies | last post: by
3 posts views Thread by sravani2 | last post: by
6 posts views Thread by oooobs | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.