Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

command line
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



Report this thread to moderator Post Follow-up to this message
Old Post
Jean Pierre Daviau
04-25-05 01:55 AM


Re: command line
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

Report this thread to moderator Post Follow-up to this message
Old Post
Oli Filth
04-25-05 01:55 AM


Re: command line
Can 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



Report this thread to moderator Post Follow-up to this message
Old Post
Jean Pierre Daviau
04-25-05 01:55 AM


Re: command line
Jean 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

Report this thread to moderator Post Follow-up to this message
Old Post
Oli Filth
04-25-05 01:55 AM


Re: command line
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

Report this thread to moderator Post Follow-up to this message
Old Post
Chris Hope
04-25-05 01:55 AM


Re: command line
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

Report this thread to moderator Post Follow-up to this message
Old Post
Oli Filth
04-27-05 08:56 AM


Re: command line
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

Report this thread to moderator Post Follow-up to this message
Old Post
Chris Hope
04-27-05 08:56 AM


Re: command line
Well. 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



Report this thread to moderator Post Follow-up to this message
Old Post
Jean Pierre Daviau
04-27-05 08:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:28 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.