Solved

HTTP_COOKIE - > PERL

Posted on 2006-10-23
2
902 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

17 Experts available now in Live!

Get 1:1 Help Now