Solved

HTTP_COOKIE - > PERL

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

20 Experts available now in Live!

Get 1:1 Help Now