Re: Closing Session (Revisited)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 05 May 2011 08:28:53 -0400, sstaples@xxxxxxxx (Steve Staples) wrote:

>On Thu, 2011-05-05 at 21:41 +1000, Roger Riordan wrote:
>> 
>> I have developed a common engine which I use for several different websites. I had been
>> using PHP 5.2.? and IE6 (yes; I know!), and had been able to have multiple sessions open
>> at once, displaying the same or different websites, without them interfering with each
>> other. This was incredibly useful; I could be looking at, or even edit, different parts of
>> the same, or different, websites simultaneously without any problems.
>> 
>> But I recently had a hard disk crash and had to re-install all the system software. Now I
>> have PHP 5.3 and IE 8, and find that if I try to do this the various sessions interfere
>> with each other. From the above comment I gather that this is because IE 8 combines all
>> the instances, whereas previously each instance was treated as a different user.
>> 
>> Is there any simple way to make IE 8 treat each instance as a new user, or should I switch
>> to Chrome and use the Incognito feature?
>> 
>> Roger Riordan AM
>> http://www.corybas.com/
>> 
>
>The Incognito feature wont give you the results you're looking for.
>>From my experience, the incognito window(s) and tab(s) share the same
>memory/cookie/session space, which is different from the main window...
>which means you will run into the same issue.
>
>Once you close all your incognito windows/tabs, you will release those
>cookies/sessions/memory space and if you open a new one afterwards, then
>you will be fine, but if one tabs stays open, no go :(
>
>Have you looked at the http://ca3.php.net/session_name function, and
>putting that into your site just after your session_start() ?  I believe
>that will fix your issues (as long as your session names are unique),
>but i am not 100% sure.
>
>Steve
>

Thank you for this suggestion. This has solved the more serious half of my problems; I can
easily generate a different session name for each website, so that the various websites
don't interfere with each other, but I have not been able to devise a way to differentiate
between multiple sessions of the same website.

For example, if I open one copy of a website as a visitor I am shown as Visitor, but if I
then open another window, and log in as Manager, then go back to the first window I am
shown as Manager (with appropriate privileges) there also.

The only way I can think of to overcome this would be to generate a new named session
every time I log in, and then to pass the session name as a parameter every time I load a
new page. Unfortunately my program is sufficiently complicated that this is effectively
impractical, as it would involve tracking down and modifying every point in the program at
which a new page can be launched.

It also has a theoretical disadvantage that if someone bookmarks a page they will book
mark the session name, but this can fairly readily be overcome.

Is there any alternative way in which a different session name (or equivalent flag) can be
attached to each instance of the browser?

(Effectively these problems only affect the developer, as they only apply to multiple
instances of the same browser on the same PC.)


PS. At this stage I devised a really nasty kludge, which enables me to run multiple copies
without them interfering. In my program new pages are always launched by a command of the
general type:

http://localhost/cypalda.com/index.php?level=1&item=22

This loads the file index.php, which is a very brief file in the public directory
(cypalda.com in this case). It sets a couple of constants and then transfers control to a
file Begin.php, in a private directory. This in turn sets up a whole lot more constants,
and then transfers control to the main program, which is common to 5 different websites.

I realised that if I specify the session name in index.php, I can make several copies of
this file, e.g. index.php, index1.php, index2.php, each of which specified a different
session name. I thought this still left me the problem of modifying all the points at
which a new page was launched, but then I found that by great good fortune (or foresight!)
I had defined a constant $home_page = index.php, and always launched a new page with the
basic command
echo ('<a href="'.$home_page.'?ident=' ....... >');

So all I had to do to achieve the desired outcome was to specify a different $homepage in
each copy of index.php. Then, once I had launched a particular copy of index.php, that
instance of the browser would always load the session appropriate to that copy.

Even better, if I upload the various versions of index.php, I can run multiple copies of
the public website on the same PC without them interfering.


Roger Riordan AM
http://www.corybas.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux