Solved

cookies and redirection

Posted on 2000-04-18
9
268 Views
Last Modified: 2013-12-25
I'm kind of new at cgi, and have a question about using cookies. I simply want to redirect the user to 1 of 2 URL's based on whether they have been to the site before. I know how to set a cookie, but i'm not sure how to use the cookie to determine if the user has already accessed the page. I assume some type of "if" "else" type code. Could someone email a script, or point me to where i could find example scripts. Ive looked a lot, but most sites show only how to create cookies. I'm using perl 5x.
Lisa.
0
Comment
Question by:wolverina
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 1

Expert Comment

by:hkmdj
Comment Utility
0
 

Author Comment

by:wolverina
Comment Utility
Thanx, however ive been there already... meow..!!!

Lisa.
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
If you are not a member of the Perl-win32-web or Perl-win32-users mailing list, I suggest you join.  They have been active for over 4 years that I know of and are a HUGE pool of talent.  You can join here; http://www.activestate.com/support/mailing_lists.htm

While it doesn't answer your question, it will help your quest for a solution.

I do this very easily in .asp pages, the function is the same...;

<%
' Check for the cookie
Cookie = Request.Cookies("Wine")
%>
<% ElseIf Action="New" Then
            If Cookie = "" Then
Response.Redirect "nope.asp"
%>
      <% Else %>
            <!--#include file="nblank.inc"-->
            <% End If %>
<% End If %>
0
 

Author Comment

by:wolverina
Comment Utility
Thanx, i appreciate the info. There's more code for javascript than perl, so i'm using that instead. I'm going to delete the question in a couple days. :)

Lisa.  
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 2

Accepted Solution

by:
chuckie79 earned 150 total points
Comment Utility
Perl solution could be as follows

# Get Cookies using CGI.pm
# http://www.perl.com/CPAN-local/modules/by-module/CGI/CGI.pm-2.66.tar.gz
# http://www.perl.com/CPAN-local/modules/by-module/CGI/CGI.pm-2.66.readme
use CGI.pm

$test_cookie = cookie("firstvisit")
if ($text_cookie eq "yes")
{
  print "Location: http://www.something.com/secondvisit.html\n\n";
}
else
{
  print "Location: http://www.something.com/firstvisit.html\n\n";
}
0
 
LVL 2

Expert Comment

by:chuckie79
Comment Utility
Sorry didn't read the original question very well. The above answer is for reading a cookie, have a look at the readme for CGI.pm. This module should cover most of what you probably would want to do.
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
Why don't you just add a value to the cookie file that is created when the cookie is, like PageId=1, then if you check the cookie upon entering a page it is simply a matter of checking the pageId in the cookie and redirect if true.

You know you can always modify an existing cookie...

Take a look at the HTTP::Cookie.pm module in your Perl load.
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
Why don't you just add a value to the cookie file that is created when the cookie is, like PageId=1, then if you check the cookie upon entering a page it is simply a matter of checking the pageId in the cookie and redirect if true.

You know you can always modify an existing cookie...

Take a look at the HTTP::Cookie.pm module in your Perl load.
0
 

Author Comment

by:wolverina
Comment Utility
Thanx... ive figured it out in both perl and javascript now. Thanks again,
bye.

Lisa.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now