0

I'm new to PHP and I learn sessions right now, so I tried to to create two files, one that creates the session var and one who prints it.. here's the code: session1.php

<?php session_start(); $_SESSION['a'] = 1;  echo 'The session right now is: ' . $_SESSION['a']; ?>

session2.php

<?php
session_start();
if(isset($_SESSION['a']))
{
    echo $_SESSION['a'];
}
else
{
echo 'but the output here is false';
}
?>

First I enter to session1.php to create the session, then I go to session2.php and the output is false.. This only happens when this files are uploaded to the web hosting, you are welcome to try it yourself in this url: wwww.pzwhatsup.com/session1.php and wwww.pzwhatsup.com/session2.php. When trying this in my computer with wamp, it works perfectly..

4

2 回答 2

1

Does your hosting company allow Sessions, and did they give a valid path with the proper rights for storing the sessions?

It happens.

Else, do you request the two files right after each other (include or somthing), or is there a page switch in between?

Cause when you set a Session value and request it right after (miliseconds) your value isn't always set properly.

于 2013-03-30T19:15:58.200 回答
1

Some web hosters dont create the session's repertory, so try to read your webhoster's terms of using, maybe you would find something about creating your own session repertory.

于 2013-03-30T19:17:28.577 回答