sessions and cookies

Forum for you who has PHP installation issues

Moderators: macek, egami, gesf

Tjobbe
New php-forum User
New php-forum User
Posts: 2
Joined: Tue Aug 05, 2003 5:03 am
Location: Barcelona (Spain)
Contact:

sessions and cookies

Postby Tjobbe » Sat Aug 16, 2003 12:45 pm

Hello everyone!

I'm trying to use session variables and cookies on my "localhost".

The first file is ett.php, with the following code.

<?php
session_start();
header("Cache-control: private");
$_SESSION["out"] = "tjenare";
?>
<html>
<head>
<title></title>
</head>
<body>
<a href="tva.php">GO</a>
</body>
</html>

The receiving file is tva.php, with the following code.

<?php
session_start();
header("Cache-control: private");
?>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
$out = $_SESSION["out"];
echo "Out = $out";
?>
</body>
</html>

I dont get this to work!
Should I change any installations in PHP:INI or??????????????

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Sat Aug 16, 2003 5:03 pm

I think this should work:

Code: Select all

<?php
session_start();
header("Cache-control: private");
session_register('out);
$_SESSION["out"] = "tjenare";
?>
<html>
<head>
<title></title>
</head>
<body>
<a href="tva.php">GO</a>
</body>
</html>

The receiving file is tva.php, with the following code.

<?php
session_start();
header("Cache-control: private");
?>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
echo "Out =" .  $_SESSION["out"];
?>
</body>
</html>

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Sat Aug 16, 2003 5:23 pm

Joan Garnet wrote:I think this should work:

Code: Select all

<?php
session_start();
header("Cache-control: private");
session_register('out);
$_SESSION["out"] = "tjenare";
?>


Looks like you were missing a closing quote on the fourth line above, Joan. It ought to be session_register('out'); Simple typo, I'm sure.

By the way, Tjobbe, I ran your code on my machine and it worked fine. Do different versions of PHP handle this differently?

Joel
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand
Contact:

Postby Joel » Sat Aug 16, 2003 7:05 pm

When using $_SESSION[] variables, you do not need to use session_register().

TJobbe, are you using an old version of PHP? In older versions $_SESSION isn't available.

ngfrancisco
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Nov 06, 2003 10:43 pm
Location: Philippines
Contact:

sessions and cookies

Postby ngfrancisco » Thu Nov 06, 2003 11:16 pm

Hi!

I had the same problem before with session under windows. What I did was to create a directory sessiondata and specify it in the PHP.ini file under the session path.

I hope this will help your problem. :D

EdwardBobadilla
New php-forum User
New php-forum User
Posts: 6
Joined: Sat Dec 20, 2003 11:38 am
Location: Altadena, Pasadena, Orange County, Los Angeles
Contact:

Postby EdwardBobadilla » Mon Dec 22, 2003 4:38 pm

i tried this script which is viewable at
"http://www.nelsoncasecorp.com/test1.php" and the output is blank, and suggestions?

redhead
New php-forum User
New php-forum User
Posts: 14
Joined: Thu Mar 04, 2004 11:20 am

Re: sessions and cookies

Postby redhead » Mon Mar 08, 2004 9:55 am

ngfrancisco wrote:I had the same problem before with session under windows. What I did was to create a directory sessiondata and specify it in the PHP.ini file under the session path.


That helped me out so much just want to say thank you :-D


Return to “PHP Installation”

Who is online

Users browsing this forum: No registered users and 1 guest

cron