You are here: Re: session IDs and the like « PHP Programming Language « IT news, forums, messages
Re: session IDs and the like

Posted by Berimor on 11/06/05 20:19

On Sun, 6 Nov 2005 14:49:20 +1300, windandwaves <winandwaves@coldmail.com>
wrote:

> Berimor wrote:
> .....
>> session_start() should first in output to browser. Try to place
>> thesetcookie() after session_start().
>
> Ok, interesting ;-) Can you explain me why that is? Just so that I
> understand.. Will do

the PHP Manual says

" ... Note: If you are using cookie-based sessions, you must call
session_start() before anything is output to the browser.
"

the nature of sesion mechanism is more complex than just cookie. You can
set cookie at any place of script - you just make easy operation - write
the information to broweser's cookie. When session starts it uses cookie
only to save session identificator but behind the curtains huge piece of
work being done - session prepares the, so called, session environment. I
have never dig it deeply though :)
Let mne know if this helped.

>
>
>>
>>
>>> //function to include session ID in case they do not accept cookies
>>> function sid($withamp) {
>>> if($_COOKIE["CookieTest"] == "t") {
>>> return '';
>>> }
>>> $s = session_id();
>>> if($s) {
>>> if($withamp) {
>>> $v = '&amp;';
>>> }
>>> $v .= 'PHPSESSID='.$s;
>>> return $v;
>>> }
>>> }
>>> /* end of startup.php */
>
>



--
Exact Meta Search | Major Search Engine
http://exactsearcher.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

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