Solved

cookies and redirection

Posted on 2000-04-18
9
276 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
Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

 

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 150 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

695 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