codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Cookies: issue with retrieving?  andrewg at 06:04 on Thursday, September 01, 2005
 

homegrown perl developer usually on linux, but this is on windows box, but not sure that matters....

i get:

Can't call method "cookie" on an undefined value at \cgi-bin\article_admin.pl line 11.

error when trying to retrieve cookie value (for a cookie of name 'articles' that i set on a previous page) via CGI in order to test whether user should have access to this page. the relevant code snippet is below. not sure why it would have an undefined value? can anyone help, as i'm undoubtedly just being stupid but am working alone right now and very stuck. thanks.

1#!/usr/bin/perl -w
2
3 use strict;
4
5 use CGI;
6 use CGI::Carp qw(fatalsToBrowser);
7
8 my $query = new CGI;
9 my $cgi;
10 my $cookie_exists ="no";
11 $cookie_exists = $cgi->cookie('articles');

  Re: Cookies: issue with retrieving?  S_Flex at 11:51 on Sunday, April 23, 2006
 

#!/usr/bin/perl -Tw

use strict;

use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $query = new CGI;
# my $cgi; # Dont need this

my $cookie_exists = $query->cookie('articles'); # Use $query a defined value and the one in this code that will use CGI.pm to get the cookie
if(!$cookie_exists) { $cookie_exists = 'no'; }



This was your main problem $cgi->cookie('articles'); becase you called my $query = new CGI; the get cookie will need to use $query->cookie('articles'); and my $cgi; is not needed.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Digital.Canal.Software.V2013
•  Altair_HyperWorks_12.0.1_Win64
•  Global.mapper.V15.0
•  ESI.PAM-RTM.V2010.0
•  KISSsoft.03.2013E.SP5
•  Technical.Toolboxes.Pipeline.Toolbox.2013.Enterprise.v15.0.0
•  Simprotek.Simprosys.V3.0
•  Ricardo.SABR.V6.0p1
•  PSIM.V9.2


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2013