CodeIgniter Forums
Strange! MS Office docs, when opened on my CI site, cause the session to be lost - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Strange! MS Office docs, when opened on my CI site, cause the session to be lost (/showthread.php?tid=24947)



Strange! MS Office docs, when opened on my CI site, cause the session to be lost - El Forum - 11-25-2009

[eluser]skattabrain[/eluser]
I have a CI app and I've written a tool that allows the users to upload their important MS Office files. So this works great, and on my client, I have no problems opening these files.

However, it turns out, on my clients network, opening any of these files from the web server causes the client to lose their session. I've gone crazy trying to understand what is going on, but I've narrowed it done to this ...

Client goes to page, I scan a directory using the file helper and present a list of all their uploaded office documents. I can set a meta refresh on this page and watch it refresh for hours and it will not lose the session. I use a php timestamp to ensure I'm not looking at cache.

When a user clicks a link to a WORD doc ... it opens in a new browser window/tab. If I leave that open, then continue using the site, my session still works fine.

The second I close the tab/window on the office doc (btw - loaded inside IE 7), it at that seconds destroys the session and the user is logged off.

Anyone ever run into this?


Strange! MS Office docs, when opened on my CI site, cause the session to be lost - El Forum - 11-25-2009

[eluser]skattabrain[/eluser]
do you think an htaccess rewrite rule could cause this? like CI first looks for a controller by the name of the file, then does some redirect to tfile after it sees it's not a controller?

Here's my htaccess ...

Code:
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>



Strange! MS Office docs, when opened on my CI site, cause the session to be lost - El Forum - 11-25-2009

[eluser]skattabrain[/eluser]
Clapping with 1 hand today it seems!

So anyways, for those that are dealing with this, I did find a fix and improved user experience at the same time, because opening up Office files in the browser has always and does ... suck anyways! PDF's too ... but that's just me. But Office files in the browser just suck. Smile

I added this to my htaccess to force certain file types to open in their native application.

Code:
<FilesMatch "\.(doc|docx|xls|xlsx|ppt|pptx|rtf|pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>



Strange! MS Office docs, when opened on my CI site, cause the session to be lost - El Forum - 11-25-2009

[eluser]BrianDHall[/eluser]
Wow, that's great. I couldn't figure how it could possibly cause a session problem, but at least that fixes it for you.

I was going to suggest trying to sniff out the headers and save your sessions in a database so you can browse them easier, to see if CI is killing the session or if the browser is just losing the cookie for some reason.


Strange! MS Office docs, when opened on my CI site, cause the session to be lost - El Forum - 11-25-2009

[eluser]skattabrain[/eluser]
I suspect it was something header related, but I don't know ... on my home and office networks I couldn't make it happen anyways. I was remotely using a browser on his network because I couldn't lose the session.

I'm using an up to date OS/browser on my dev box ... I really think it was Office blowing something up.

Didn't think of capturing the headers.


Strange! MS Office docs, when opened on my CI site, cause the session to be lost - El Forum - 11-25-2009

[eluser]CroNiX[/eluser]
Did you try opening them in an iframe?


Strange! MS Office docs, when opened on my CI site, cause the session to be lost - El Forum - 01-29-2010

[eluser]AlexKrenvalk[/eluser]
[quote author="skattabrain" date="1259188701"]Clapping with 1 hand today it seems!

So anyways, for those that are dealing with this, I did find a fix and improved user experience at the same time, because opening up Office files in the browser has always and does ... suck anyways! PDF's too ... but that's just me. But Office files in the browser just suck. Smile

I added this to my htaccess to force certain file types to open in their native application.

Code:
<FilesMatch "\.(doc|docx|xls|xlsx|ppt|pptx|rtf|pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
[/quote]
Some days ago I worked with my office files.But today when I opened one of it,I was scared,because all data in it was lost.Fortunately a friend advised me-Fix Word file docx.Software solved my problems in a minute and free of charge.Moreover I knew how tool effectively recover the text information from corrupted Microsoft Word documents and templates.