Previous Thread
Next Thread
Print Thread
Rate Thread
#103175 10/02/2001 8:14 PM
Joined: Oct 2000
Posts: 743
Moderator / Code Fixer
Moderator / Code Fixer
Offline
Joined: Oct 2000
Posts: 743
Im just having a play with cookies and im stuck on this. I just want to be able to store a value in a cookie and retreive it at a given time.
So I use the statement
Code
code:

This the below code could create a cookie called "username" and set the value to "my name"
Code
code:

this code should retreive the cookie

Code
code:

But for some reason its either not storing the cookie correctly or retreiving the cookie correctly. Have I missed something here?
Any help appreciated.

Thanks!


I can't afford a good signature editor frown
Sponsored Links
#103176 10/02/2001 10:47 PM
Joined: Aug 2000
Posts: 335
Member
Member
Offline
Joined: Aug 2000
Posts: 335
$to_set is a reference to a Perl cookie object. The cookie doesn't actually get sent to the browser until it's output in an HTTP header. The CGI.pm documentation illustrates how to do this.

The cookie has to be fetched by a separate HTTP request, e.g., a separate invocation of a script.

#103177 10/03/2001 9:46 AM
Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
ok... this is the way i use;

Code
code:

also, you must set cookie inside the header method & you must print the cookie before the header as the code above...

if you call this code after printing header, it wont work...

[ 10-03-2001: Message edited by: jeologic ]

#103178 10/07/2001 7:24 PM
Joined: Oct 2000
Posts: 743
Moderator / Code Fixer
Moderator / Code Fixer
Offline
Joined: Oct 2000
Posts: 743
Hmm I cant seem to work this out.
Ive tried

Code
code:

and im left with a blank screen.

What I basically need to do is.
A subroutine is called, when its called I need to get the value of a cookie, if its not blank then 'do this' else 'do that' and set the value ot the cookie to 'blah'.

How could that be acheived?

Thank You.


I can't afford a good signature editor frown
#103179 10/11/2001 6:09 PM
Joined: Oct 2000
Posts: 743
Moderator / Code Fixer
Moderator / Code Fixer
Offline
Joined: Oct 2000
Posts: 743
Anyone, all there Perl Gurus around here and no suggestions smile ?
Thanks


I can't afford a good signature editor frown
Sponsored Links
#103180 10/12/2001 6:38 AM
Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
as I said... first set the cookie, then print the http header. it must work...

enable warnings and use CGI::Carp to see the error..

Code
code:

also, $query is a CGI object;

Code
code:


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)