Re: CGI::Session --help
by oxone (Friar) on Aug 28, 2007 at 11:19 UTC
|
There are two common ways to give CGI::Session a persistent session ID from the user's browser in order to track login status etc.
The first way is to drop a cookie, and this method won't allow you to do what you ask. For a given domain+browser a cookie is 'shared' so all of your tabs in Firefox will be getting the same login/logout status. This is often what's wanted anyway, but not in your example.
The other method is to preserve the session ID by passing it from page to page as a parameter in the URL. So, your login creates a session ID, and then your scripts need to ensure that each page keeps passing it on via the URL. This would enable you to do what you want. There's info in the CGI::Session tutorial about this.
Note that this second method has the disadvantage of always 'forgetting' each user entirely after logout, whereas using a cookie means a user's session ID can be made available to be re-used on their next login.
| [reply] |
|
|
| [reply] |
|
|
use CGI::Session ( '-ip_match' );
which will only allow the session if it's coming from the same IP number (downside: if your ISP changes your IP address mid-session, you'll be logged out).
Also you can improve things a little by timing out the session relatively quickly.
It's worth noting that the same security hole exists using cookies, in that somebody with a copy of your cookie could get access as you. It's just that it's a little harder for you to publish your cookie inadvertently.
| [reply] [d/l] |
|
|
|
|
Re: CGI::Session --help
by moritz (Cardinal) on Aug 28, 2007 at 11:10 UTC
|
Usually session information is stored in cookies, which are shared among all browser windows/tabs.
So if you log in in one tab, and then refresh the other windows you should be logged in in all tabs. And if you close one of them, that doesn't affect the other windows.
And if you log out explictly in one tab, you delete the session information on the server, so the next time you refresh the page in any browser tab you are looged it.
That's the default behaviour, and everything else is rather hard and clumsy to implement.
And never forget that the current logged in / logged out status is only visible after you refresh the page.
| [reply] |
|
|
Couple of corrections:
A logout doesn't delete the session info from the server unless the developer chooses to do so. It's more common to retain it so that the user can be greeted etc. on return
Getting the session ID from the cookie is one of two default behaviours. The other is to look for a CGISESSID among the URL parameters. The latter method has disadvantages but would solve this requirement in that each 'tab' could then have its own session and login status.
| [reply] |
|
|
| [reply] |
|
|
Cookies are stored on a per host basis, so depending on how smart your browser is, you may be able to log into http://127.0.0.1 as one user and http://localhost. You should be able to have one session for each different name that points at your server. (you'll need to make sure your webserver maps these additional names to the correct vhost too)
Wether your CGI scripts generate urls in a way that will function correctly under this situation is another question.
I generally have 2 or 3 aliases to my hosts as part of the way the network is set up... one by name (nick), one by service (web, cvs etc), one for the literal IP (server22 for 192.168.5.22 when servers only live on 192.168.5)
@_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;
| [reply] [d/l] [select] |
Re: CGI::Session --help
by Anonymous Monk on Aug 28, 2007 at 11:05 UTC
|
I must say that I am storing the session files in /tmp/sessions eg., $session = new CGI::Session(undef ,undef, {Directory=>'/tmp/sessions/'});
-- Thnks Cherry
| [reply] |
Re: CGI::Session --help
by Anonymous Monk on Aug 29, 2007 at 05:14 UTC
|
You want to write your own browser | [reply] |