[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

cookies and redirection

Posted on 2000-04-18
9
Medium Priority
?
282 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
 

Author Comment

by:wolverina
ID: 2733135
Thanx, however ive been there already... meow..!!!

Lisa.
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 2740510
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:wolverina
ID: 2740867
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
 
LVL 2

Accepted Solution

by:
chuckie79 earned 450 total points
ID: 2756571
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
ID: 2756579
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
ID: 2756746
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
ID: 2756777
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
ID: 2757670
Thanx... ive figured it out in both perl and javascript now. Thanks again,
bye.

Lisa.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month17 days, 15 hours left to enroll

829 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