Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: creating and Deleting a new cookie

by kennethk (Abbot)
on Jun 26, 2017 at 17:40 UTC ( #1193611=note: print w/replies, xml ) Need Help??


in reply to Re^2: creating and Deleting a new cookie
in thread creating and Deleting a new cookie

When you look at the network transactions in the Network tab of Firefox DevTools (right-click, inspect element), you don't see any mention of your cookie in the Header or Cookies tabs? Sorry, language issues are interfering with my understanding your posts.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

  • Comment on Re^3: creating and Deleting a new cookie

Replies are listed 'Best First'.
Re^4: creating and Deleting a new cookie
by tsdesai (Acolyte) on Jun 27, 2017 at 06:53 UTC
    I am sorry, i am unable to explain properly.I have just checked the network tab as you mentioned and it says no cookies for this request. I am really unsure what i am doing wrong. I have gone through various examples. I have also tried to run from command prompt as one of the monks suggested, all i can see is the output of the html page but no luck while creating cookies. I would really appreciate any help on this. Many Thanks, Teju

      i added #!/usr/bin/perl to the top of your program, ran it on my test server and it worked just fine

      in firefox, click tools->web developer->network. paste the address of your page into the address bar and press enter. In the lower part of the screen make sure the all tab is selected and click on the line with status 200. the lower half splits into two panes, the right side should have the tab headers hilighted. look for set-cookie in red, and see what is next to it.

      if you see  Set-Cookie: "pass=xxxx; path=/; expires=Tue, 27-Jun-2017 08:19:23 GMT" then the cookie is getting sent, and any reason it is not used by the browser is not the fault of perl but the browser.

      If you dont see any "set-cookie" line then i suggest you are not running right file on the server. add this to the bottom of your program print 'hi there'; and copy the file to your cgi directory again. now go to your page with the network section still showing, it should now show "hi there" on the top of the screen. If it does not you are not putting your program in the right place. if it does, click on the stats 200 line again, and look on the right under the headers tab for the set-cookie header.

        Hi Huck, Thank you for your input. The line !/usr/bin/perl always there in my code except that i accidentally didn't put on the forum. I have just managed to work with one additional change and its started to work. As i have multiple print statement in the code as in I am setting the cookie and then redirect the user to the url. It either redirects or writes the cookie. though, i have found work around to it , I am not sure whether that is the right way to do it. My code after the cookies started working.
        use strict; use CGI; my $q = new CGI; my $returnurl; my $pass=$q->cookie('pass'); my $JsessCookie = $q->cookie(-name=>$pass, -value=>'', -path=>'/', -ex +pires=>'-1h'); my $tempcookie = $q->cookie(-name=>'tempc', -value=>'', -path=>'/'); my $url="https://test.com/return=$returnurl"; #tried the below but doesn't redirect <b>shows 302 status</b> #print $q->redirect(-cookie=>[$JsessCookie,$tempcookie],-uri=>$url); #<b>this is the working redirection code- but not sure whether its the + right way forward</b> print $q->header(-cookie=>[$JsessCookie,$tempcookie]); print qq~<meta http-equiv="refresh" content="0;URL=$url">\n;
        Many Thanks for all your help so far
Re^4: creating and Deleting a new cookie
by tsdesai (Acolyte) on Jun 28, 2017 at 07:33 UTC
    Hello, Thank you for your input. The line !/usr/bin/perl always there in my code except that i accidentally didn't put on the forum. I have just managed to work with one additional change and its started to work. As i have multiple print statement in the code as in I am setting the cookie and then redirect the user to the url. It either redirects or writes the cookie. though, i have found work around to it , I am not sure whether that is the right way to do it. My code after the cookies started working.
    use strict; use CGI; my $q = new CGI; my $returnurl; my $pass=$q->cookie('pass'); my $JsessCookie = $q->cookie(-name=>$pass, -value=>'', -path=>'/', -ex +pires=>'-1h'); my $tempcookie = $q->cookie(-name=>'tempc', -value=>'', -path=>'/'); my $url="https://test.com/return=$returnurl"; #tried the below but doesn't redirect <b>shows 302 status</b> #print $q->redirect(-cookie=>[$JsessCookie,$tempcookie],-uri=>$url); #<b>this is the working redirection code- but not sure whether its the + right way forward</b> print $q->header(-cookie=>[$JsessCookie,$tempcookie]); print qq~<meta http-equiv="refresh" content="0;URL=$url">\n;
    Many Thanks for all your help so far

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1193611]
help
Chatterbox?
[erix]: More Loudness! Schnittke - choir concerto
[erix]: (not for the easil. am.)

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2017-10-23 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (282 votes). Check out past polls.

    Notices?