Jump to content

Sessions is killing me


mskl

Recommended Posts

I have PHP5.2.1, MySQL5.0, and Apache2.2 which I thought was working fine.  I created databases using PHP/MySQL for Dummies, and also the database in Foundation PHP for Dreamweaver8.  ZenCart created its database fine.

 

I have now installed Cartweaver and I simply cannot get anything that requires an input from me to work.  I have been in constant contact with Tom Muck, one of the developers and he tells me the problem is with sessions.  He gave me a little program to test sessions:

 

<?php

session_start();

echo("Testing Sessions:<br>");

if(!isset($_SESSION["test"])) {

$_SESSION["test"] = "test";

}else{

echo ("Sessions work");

}

?>

 

This doesn't work.  However, I used two other little PHP programs from the Dummies book, which passed 2 variables from one page to another using sessions and it worked.

 

I have the following statements in my php.ini file:

session.use_trans_sid = 1

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

 

What else can I do to get sessions to work properly.  I was told to:

"to make sure that PHP has permission to write to that session directory you mentioned".

 

Can anybody help me?  I have been working on this for 3 days.

BTW, I am using Vista, unfortunately.

 

 

Link to comment
https://forums.phpfreaks.com/topic/38987-sessions-is-killing-me/
Share on other sites

i am not sure if there is another source file you forgot to paste but if there isnt that is the problem

 

create a file

 

index.php

 

<?php
session_start();
$_SESSION['name'] = 'value';
echo $_SESSION['name'];
?>

 

run the script then remove the line that says $_SESSION['name'] = 'value' and reload the page, if nothing is displayed let me know. (make sure cookies are enabled in your web browser if the above does not work

I think I did it right.  I copied the code into a dreamweaver site into a file called sessions_tester.php and ran it in IE7.  I got "value" at the top of the screen.  I then deleted the line you said, and hit the refresh button on IE7.  "value" stayed at the top of the page.

Does that mean sessions is working.

 

Mike

Correction,

I did it again, this time remembering to save the revised sessions_tester.php file and when I hit refresh I got the following:

 

Notice: Undefined index: name in C:\Apache Sites\phpdw\session_tester.php on line 5

 

I guess that means sessions isn't working properly.

 

Mike

 

Try this session tester:

<?php
sesssion_start();
if (!isset($_SESSION['test'])) $_SESSION['test'] = 0;
else $_SESSION['test']++;
echo 'Number of times loaded: ' . $_SESSION['test'];
?>

 

If sessions are working then each time you refresh the browser window showing this script, the number will increment by 1.

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.