Code Comments
Programming Forum and web based access to our favorite programming groups.Hi,
Can we set a cookie from the command line.
I have tried
<?php
setcookie('TestCookie','allo',time()+360
0);
echo "->".isset($_COOKIE['TestCookie']);
?>
echo gives: ->
--
X trême newbe
......
masm32
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
Post Follow-up to this messageJean Pierre Daviau wrote:
> Hi,
>
> Can we set a cookie from the command line.
> I have tried
> <?php
> setcookie('TestCookie','allo',time()+360
0);
> echo "->".isset($_COOKIE['TestCookie']);
> ?>
>
> echo gives: ->
Firstly, even with a browser, the echo statement will be empty until the
page is refreshed, because setcookie("TestCookie", ...) does not set
$_COOKIE["TestCookie"] directly.
Secondly, with the command line, how could the cookie possibly be
transferred or stored? There is no browser, and hence no HTTP transfer,
and hence no HTTP headers, and hence no cookie transfer.
--
Oli
Post Follow-up to this messageCan it be done?
Sending the headers, etc.?
"Oli Filth" <catch@olifilth.co.uk> a écrit dans le message de news:
IQ8ae.730$p06.375@newsfe3-gui.ntli.net...
| Jean Pierre Daviau wrote:
| > Hi,
| >
| > Can we set a cookie from the command line.
| > I have tried
| > <?php
| > setcookie('TestCookie','allo',time()+360
0);
| > echo "->".isset($_COOKIE['TestCookie']);
| > ?>
| >
| > echo gives: ->
|
| Firstly, even with a browser, the echo statement will be empty until the
| page is refreshed, because setcookie("TestCookie", ...) does not set
| $_COOKIE["TestCookie"] directly.
|
| Secondly, with the command line, how could the cookie possibly be
| transferred or stored? There is no browser, and hence no HTTP transfer,
| and hence no HTTP headers, and hence no cookie transfer.
|
|
|
| --
| Oli
Post Follow-up to this messageJean Pierre Daviau wrote: > Can it be done? > > Sending the headers, etc.? > No! Think about it! You're at the command line, so you're not *sending* anything anywhere. There is no server, and no client. HTTP and TCP/IP are not involved. At the command line, PHP has nothing to do with the web, it's a stand-alone scripting language. And you're not in a browser, so the concept of cookies is meaningless. Just as URLs, HTML, CSS and forms are meaningless in a command-line context. I suggest that you spend some time reading up about how web-browsing and the internet actually work, you'll understand what PHP *does* a lot better. If you don't, everything PHP does might as well be "magic". ;) -- Oli
Post Follow-up to this messageJean Pierre Daviau wrote: > Can it be done? > > Sending the headers, etc.? What are you actually trying to do? Headers, cookies etc are meaningless from the command line as Oli pointed out. -- Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Post Follow-up to this messageJean Pierre Daviau wrote:
> Hi,
>
> Can we set a cookie from the command line.
> I have tried
> <?php
> setcookie('TestCookie','allo',time()+360
0);
> echo "->".isset($_COOKIE['TestCookie']);
> ?>
>
> echo gives: ->
Firstly, even with a browser, the echo statement will be empty until the
page is refreshed, because setcookie("TestCookie", ...) does not set
$_COOKIE["TestCookie"] directly.
Secondly, with the command line, how could the cookie possibly be
transferred or stored? There is no browser, and hence no HTTP transfer,
and hence no HTTP headers, and hence no cookie transfer.
--
Oli
Post Follow-up to this messageJean Pierre Daviau wrote: > Can it be done? > > Sending the headers, etc.? What are you actually trying to do? Headers, cookies etc are meaningless from the command line as Oli pointed out. -- Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Post Follow-up to this messageWell. Ok. I thought it would have been interesting to test snip of codes. I know I can test them with a Browser. In fact I use easy hp for that. Thank to you (s). N.B: (s) means many of you. "Chris Hope" <blackhole@electrictoolbox.com> a écrit dans le message de news: d4c59c$om4$1@lust.ihug.co.nz... | Jean Pierre Daviau wrote: | | > Can it be done? | > | > Sending the headers, etc.? | | What are you actually trying to do? Headers, cookies etc are meaningless | from the command line as Oli pointed out. | | -- | Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.