Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: CGI Session question

by magog (Beadle)
on Jun 11, 2005 at 07:41 UTC ( [id://465767]=note: print w/replies, xml ) Need Help??


in reply to CGI Session question

It's probably safest to both set a cookie and also put it in the query string. That means modifying every link you generate for the user.

Of course, that gives you really long and ugly URLs with a lot of noise in them.

So the first time you receive user's session ID in a cookie, you could set a "cookies work" flag in the user's session. From then on you can stop adding the session ID to the links you generate. If the user loses the cookie, you start them over with a new session.

Another strategy would be to start by assuming that cookies work. The first time you receive a cookie-less request for any page that isn't the main entry page to your site, you start adding the session ID to the query string.

Michael

Replies are listed 'Best First'.
Re^2: CGI Session question
by kaif (Friar) on Jun 13, 2005 at 02:31 UTC

    I've always personally been a believer in the "have multiple ways of doing things and fallback on a backup method if the first method doesn't work", both in personal coding (sometimes some modules work on different platforms and sometimes they don't; sometimes you have a newer Perl, sometimes an older one; etc.) and on website-related things.

    Is anyone aware of any sites online that let the user choose between session-handling methods: between cookies, GET or POST?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://465767]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-23 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found