Solved

HTTP_COOKIE - > PERL

Posted on 2006-10-23
2
909 Views
Last Modified: 2008-02-01
Hi

use CGI;


MAIN:
{
my $cgi = CGI->new();

#!/usr/bin/perl

$cookie = $ENV{HTTP_COOKIE}

    print "Content-type: text/html\n\n";

    print "<PRE>$cookie</PRE><P>";

}

}


when I run above script the output is

DoesThisWork="yes"; SMIDENTITY=KJ6wsaNv3X9XA1SgBFE+5ZDKGwpOdxS5G/v2nad24cB68kRclUh0PjPE9kkXOYJ8Gjq+muAmnxh6+8G2532NmzNKjG0eVj247kQO59SkfASyIZ5uf33DmMpi4YfZ+KVFsxrOAnqH+nNIt0a/eCcWyWQu0hvcVamLX/hrbdczBHlDFh1KoCyxJvGcZvniEoaGDzvAmfmBKfFwFhZaECrQoBgAxV704qjLnQIhYHI6lmTIpIHCmgj3jqzF5T9rkujz7HD62VLA2LBFAtMMtyKQltTwId8u/JvBTXufLBeVE0f5UUctB0c92TBCU7Dx5zWTW0UUEMIE40DxDYNNe/wFgLYseSfiFeJ0ULCP6XgUVqDjhxGNVoVvFjMlm2/sqyLVARGr1bYnbIT7eTPIfx5Q9Silw7cExIL817d4zQLEuBQj34nuIXFC3/p6cXMoYaBKEiOx/4wH1CopvSUTHRCikuHTxSzx8etM1OKlWB9WvRmVMHtn8jJSZ1MLf3qUx0sraDJux2ZDnpKJRdfADpAS+KzWHE5CCiLFlwL9VjIPMvac2augrt808hbTEbi0k21U5vH5ljHGTsTg2hLC6eKCAqAUeq9/FpcL; SMSESSION=UjCMUWSubpsodqEfv5TeugVB5+obytGF8uce8M1uhhrhKz8uJHFMzpKY+Ncf21pRdN+b+xyCVowoOb0RRWqZcZSeZmmZsKZNyKd5RmyrBOzPaogFyB2n8qjrg2kzLP+rdjLrnJb8/IvDViKsuohICcbua+0rTZBkB0D7z82PlwmCoIPSAaWi6cZsfNFVOs435Qpi7P3YKPpSrhMnk2UwMQZ37nhbwBSfJ2uIH4xn4ttDXJLAoZOhw030rX9ggE+/I4OCZNnvuwLB/r2mu27srsYFvrvKIsg8UO6LCJyQJqUtUYkz/VWN1vAnDTvJ5gi6+TjTZr7aPS0O6JdGFTh8LjvewQm/999mjCDSo9AYbLIrFvt/TDf2Ah7IU5TiFsn9h5Q6iCcRRAboEWgz4wOUc9SGdx6ezBF2CSB1zayxC4SulYMcAuZG4PmIrVUU/bpCjpqcxnrM4mRIM3X8q79wNwZMgS4XMyo5X6/NNIuJSST+wRDFcAxbFz8Vt+nHgKq2/veI2cLiMs9Z9V6XkGRYmMN8+0GCT/KiXwZT8E6i5cLVf/F20j61sNuo63yYiDLw/s5Fq9i+j0kIlW2UMS74/eYGr/bukaGmkMPWe6I1r60OgJhVdN/x3h70nbOAoXbix8mmF2PnT4XdN1s6q37QrBKLD+oL1IefPQK3BJWtkQo5IwLi/GktOhyOHMNPsjdpjAzUTHBbxhgx2ljN7UT8LcVjG8UaTUwFBfOKtbaFV1UPW+NU6UHx8fpiyGL3HIUe1t4fQhqCOcwY9amRy5iJt8EqswUbtTNz7wjxWikEe8tXdgZHBCH4y3XPtJcE9aGT8cUWiD6B6T9wHuYLoGbS424u5QjkmUrkwuoyAhQMJBa4WEU/qSP0TBK+l5/CiZbbKVwKE3Rhrv7BEqp2Yprrc1wKJI349Dk7hXpYuZ2XtWFWg7GFUwoWWxM8kJlS2enmXFUwx6P/I928unC+MlnzWA==; email=xyz@email.com; user_id=xyz; id=123456


I want to access email, user_id and id saperatly.
Can you please help to change code so that I can access three parameters saperatly.

Thanks
0
Comment
Question by:basirana
2 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 17791335
0
 
LVL 17

Accepted Solution

by:
mjcoyne earned 500 total points
ID: 17791586
#!/usr/bin/perl -w
use strict;
use CGI;

my $cgi = CGI->new();
my $cookie = $ENV{HTTP_COOKIE};

my ($email, $user_id, $id) = ($cookie =~ /email=(\w+@\w+\.\w+);\s+user_id=(\w+);\s+id=(\d+)/);
print "Content-type: text/html\n\n";
print "<PRE>$email, $user_id, $id</PRE><P>";
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
perl match and sort unique result 2 135
Reading fields from the text file. 4 96
Perl, group, sort, count question 6 131
collecting information 2 157
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

815 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

8 Experts available now in Live!

Get 1:1 Help Now