tags:

views:

28

answers:

2

Hi! I want to export an Excel table with PHP. That table contains links to the actual website. The problem is that these links can only be seen by an authenticated user. When I click the links in the Excel file, even if I've logged in to my website (so technically there is a session already started), the page won't open, but instead redirects me to the login screen (so it starts another session).

Any solutions?

A: 

What you will probably want to do is to create a unique identifier for the user. This key would be appended to the end of the URL. When the user clicks on the URL in the file, the key would then log them into the site on the specific page they clicked on.

The generated URL would look something like this:

http://www.mysite.com/linkedpage.php?SK=asdsomerandomstring123

If they need to be saved, then the session values will need to be saved in the database either in a serialized array or individually.

There are inherent security issues with allowing login based on a key in the URL, so you will need to weigh the convenience of what you are trying to do against any security issues that will come with it.

Joseph
Yes, the security issues are something I'm trying to avoid, seeing that it's very easy for those Excel files to go just about anywhere :)However, it is very inconvenient not to have this feature ( to have to login every time you click a link in the excel).I have solved the issue with the redirect i described in the comment. However, I can't understand why it's doing that..
It may have something to do with the referrer not being from the same site. It is possible that that would cause the session cookies to not load properly.In any case, the "redirect" is going to be your best bet. And to really have fun with people, you can use the random string generation I mentioned and then just redirect if the variable exists. It won't automatically log them in, and you will take care of both the entrance from Excel and anyone trying to hack in.
Joseph
A: 

This question is bogus :)

There must be a bug in my app, because the session info is being kept when I click the link in excel.

What if you close the browser before you click the link?
Joseph