Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

cookies and redirection

Posted on 2000-04-18
9
Medium Priority
?
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 

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

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.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

618 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