session does not works!!

Problems with the Windows version of XAMPP, questions, comments, and anything related.

session does not works!!

Postby mehrzadsoft » 26. August 2006 10:48

hi all
i'm a new xampp user.
after instalation i did not changed any of its options or anything else.

i used this code below, but i can't use PHP SESSION.

could you please help me.

CODE:

page1.php
Code: Select all
<?php
session_start();

echo 'Welcome to page #1';

$_SESSION['favcolor'] = 'green';
$_SESSION['animal']  = 'cat';
$_SESSION['time']    = time();

// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';

// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
?>



Page2.php

Code: Select all
<?php
session_start();
echo("Hi, $animal -- <br>Credit: $favcolor $time");
?>



i see this error:

Code: Select all
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at F:\win--64--1--9tir85\unzipped\xampp\htdocs\www\test\session\page1.php:1) in F:\win--64--1--9tir85\unzipped\xampp\htdocs\www\test\session\page1.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at F:\win--64--1--9tir85\unzipped\xampp\htdocs\www\test\session\page1.php:1) in F:\win--64--1--9tir85\unzipped\xampp\htdocs\www\test\session\page1.php on line 2
Welcome to page #1
page 2
page 2
mehrzadsoft
 
Posts: 5
Joined: 15. May 2006 12:25
Location: Tehran, Iran

Postby Wiedmann » 26. August 2006 11:06

Code: Select all
<?php
session_start();

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at F:\win--64--1--9tir85\unzipped\xampp\htdocs\www\test\session\page1.php:1)... on line 2

There must be some output before "<?php".

BTW:
You set the session vars with:
$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();

and want retrieve them with:
echo("Hi, $animal -- <br>Credit: $favcolor $time");

You see the difference?
--> You must allways use the $_SESSION array.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

tanx

Postby mehrzadsoft » 27. August 2006 22:08

i've found it!

i use NOTEPAD and this programm adds some hidden codes at the beggining of the php file, so i had problem.

thanks for your hint about mu mistake in PAGE2.

thanks all 8)
mehrzadsoft
 
Posts: 5
Joined: 15. May 2006 12:25
Location: Tehran, Iran

Postby hoergen » 12. January 2007 08:41

That has nothing to do with buggy code. There is a unhappy configuration in php.ini

Change the session.save_path to something like

Code: Select all
session.save_path = "0;600;C:\Temp


dem hoergen
hoergen
 
Posts: 11
Joined: 12. January 2007 08:30


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 114 guests