Many many thanks for your inputs. But I feel awkward to say that still I am stuck :-(

I have made a small project with much labour but could not attach session for it. I was using the user_id as hard coded. But Now I need the user_id which is logged in ..but feeling helopless in session mngt.

Please see my responses :

- do your script headers contain a correct cookie? >> How do i know that whether it is a correct cookie ?

If so, is it also stored on disk? >> I am not aware about the location of cookies.

Does the browser send the cookie correctly back to the server? >> How do i know that ?

And before you start debugging, delete the cookies in your browser and try again. >> done For debugging it might be useful to print the cookie and session id information to a log file, and to use wireshark or a similar tool to monitor your HTTP traffic. >> I am trying it on my PC where apache is installed. so no issue abt HTTP Traffic.

# complete code of Redirected Page after login.cgi ######

#!/perl/bin/perl -wT use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use CGI::Session; use strict; use vivek::money_pm::money ; my $cgi = CGI->new; #print $cgi->header; ########### -- SPECIAL CODE FOR FIRST PAGE OF WEBSITE--############### +### # user_id is being passed from login.cgi my $login_user_id = $cgi->param('user_id'); ########### -- Creating The session--################## my $session = CGI::Session->new( undef, $cgi, {Directory=>'/tmp'} ); $session->flush(); my $cookie = $cgi->cookie(CGISESSID => $session->id ); print $cgi->header(-cookie=>$cookie); print $cgi->start_html("ADD CATEGORY"); print " sid = ", $session->id(); if ($login_user_id) { $session->param('user_id', $login_user_id) ; + } print "<BR> login_user_id = $login_user_id <BR>" ; my $user_id = $session->param('user_id'); print " us +er_id = $user_id <BR>" ; #$user_id = 'vivekjain'; ###### HTML TEMPLATE ############## print "<TABLE BORDER = 1 width = 600 cellpadding = 10> "; print "<TR > <TD colspan = 2 height = 60 width = 150 align = left> Mai +n Heading </TD></TR>" ; print "<TR > <TD height = 30 width = 175 > ll"; # Left men +u & user_left_menu () ; print "</TD> <TD valign = 'top'> MAIN PAGE" ; ############################################## print "<p class=\"heading\"> Add Payment Category Here </p> <BR>" ; ############################################## if(!$cgi->param('flag') ) { # hidden Variable & add_category_html (); } else { my $category_name = $cgi->param('category_name'); my $description = $cgi->param('description'); my $payment_category = qq { INSERT INTO PAYMENT_CATEGORY ( CAT +EGORY_NAME, CATEGORY_TYPE_ID, DESCRIPTION, SURITY_OF_RETURN, CREATE_D +ATE, IS_DELETED, USER_ID) values( '$category_name','$category_type_id +', '$description', '$surity_of_return', NOW(), 'N', '$user_id') } ; # & query_execute ($payment_category) ; print"</TD> </TR>" ; # HTML Template ends print"</TABLE>"; print $cgi->end_html(); 1; sub add_category_html { HTML CODE FOR ADDING CATEGORY }

In reply to Re^4: CGI session problem. by d0353101
in thread CGI session problem. by d0353101

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.