Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HTTP_COOKIE - > PERL

Posted on 2006-10-23
2
Medium Priority
?
922 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
[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
2 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 17791335
0
 
LVL 17

Accepted Solution

by:
mjcoyne earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
Six Sigma Control Plans

715 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