Yeah, I'm sorry. I didn't read the original flow right. AM is right and I alluded to it above. You can't print headers twice or you'll get wonky behavior. Give something like this a spin.

my $current_page = shift || die "Need a current page"; my $session = CGI::Session->new or die CGI::Session->errstr; my @pages = $session->param('authorized_pages'); push @pages, $current_page unless $pages[-1] eq $current_page; # Just a guess. $session->param( authorized_pages => \@pages ); $session->flush(); my $uri = URI->new( CGI::url() ); $uri->query("page=1"); $uri->fragment(""); print $session->header(-location => $uri, -status => 302 );

URI is in there to get the absolute URI and mess with the query string and fragment. Munging URI as strings is like parsing HTML with regexes. It can be done but it's error prone and why shoot yourself in the foot when there are great tools that are just as easy, if not easier.


In reply to Re^3: Unable to create session, add params, and redirect by Your Mother
in thread Unable to create session, add params, and redirect by bradcathey

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.