wolverina
asked on
cookies and redirection
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.
Lisa.
ASKER
Thanx, however ive been there already... meow..!!!
Lisa.
Lisa.
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 %>
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 %>
ASKER
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.
Lisa.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
You know you can always modify an existing cookie...
Take a look at the HTTP::Cookie.pm module in your Perl load.
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.
You know you can always modify an existing cookie...
Take a look at the HTTP::Cookie.pm module in your Perl load.
ASKER
Thanx... ive figured it out in both perl and javascript now. Thanks again,
bye.
Lisa.
bye.
Lisa.
http://perl.about.com/compute/perl/library/weekly/aa031400d.htm?iam=dp&terms=perl+read+cookie