You are here: Re: [PHP] Sessions « PHP « IT news, forums, messages
Re: [PHP] Sessions

Posted by Greg Donald on 06/15/05 20:50

On 6/15/05, Brian D. McGrew <brian@visionpro.com> wrote:
> Greetings from San Diego!

Greetings from someplace-else.

> I call session_start() on all my pages and then <? echo session_id(); ?>
> and everything is the same from all the pages. However if I stuff a
> variable into $_SESSION it's never transferred between pages. So if I
> do a <? $_SESSION["Username"] = "Brian"; ?> and then go to another page
> and say <? echo $_SESSION["Username"]; ?> it comes back blank.
>
> It doesn't seem to matter if I enclose the Username in double quotes """
> or single quotes ''' or nothing; I have no data. But like I said, the
> session id is being passed around just fine.

You have two options:

1) Pass the session name and id between pages.

<?php

session_start();

$_SESSION[ 'var' ] = 'blah';

$sn = session_name();
$sid = session_id();

echo <<<EOF
< a href="nextpage.php?$sn=$sid">Link</a>
EOF;

?>

2) Use transparent sessions (cookie based).

ini_set("session.use_trans_sid", 1);


--
Greg Donald
Zend Certified Engineer
http://destiney.com/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация