Reply to Re: Sessions

Your name:

Reply:


Posted by theCancerus on 12/11/06 06:37

hello Nico,

i think you have disabled the cookies in you browser... that is one
reason why session works with SID but not without. For session to work
properly session id is by default saved as cookies.

i can't think of any other reason... other then their is also a bug in
PHP where in session sometimes does not work and works other times.. so
my suggestion if cookies are all fine then use SID.

cheers
Amit



On Dec 11, 1:24 am, Nico <noem...@noemail.com> wrote:
> Hi,
>
> Actually it's quite strange.
> I know it's correct, but it doesn't work.
> I changed all the necessary things (e.g. aktry.php...)
> I suppose to have a problem with session in my localhost.
> If I try the example related to sessions and included in the official
> php manual:
>
> <?php
> // page1.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>';
> ?>
>
> <?php
> // page2.php
>
> session_start();
>
> echo 'Welcome to page #2<br />';
>
> echo $_SESSION['favcolor']; // green
> echo $_SESSION['animal']; // cat
> echo date('Y m d H:i:s', $_SESSION['time']);
>
> // You may want to use SID here, like we did in page1.php
> echo '<br /><a href="page1.php">page 1</a>';
> ?>
>
> I've the following result:
>
> "Welcome to page #1
> page 2
> page 2"
>
> If I visit the first link:
>
> "Welcome to page #2
> 1970 01 01 01:00:00
> page 1"
>
> If I vist the second link:
>
> "Welcome to page #2
> greencat2006 12 10 21:24:02
> page 1"
>
> It seems that in the first case sessions don't work.
> Why? I'm not able to understand.
> Can you help me please?
> Should I change something in my php.ini or httpd.conf?
> Many thanks.
>
> Cheers,
> Nico
>
> In article <1165780715.458164.109...@16g2000cwy.googlegroups.com>,
>
> "theCancerus" <thecance...@gmail.com> wrote:
> > hi Nico
> > the example i provided to you works but for it to work you must "submit
> > your form, via input with
> > > type="submit" as pointed above....
>
> > also replace aktry.php in my example with name of the file in which the
> > code was saved
>
> > it will work with out fail.. in case it does not the canyou show me the
> > exact out put what it dispalys

[Back to original 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

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