This is a discussion on Session and link within the PHP Language forums, part of the PHP Programming Forums category; I've to create link to a new page using session variables. I've about 20 variables already set, so ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I've to create link to a new page using session variables.
I've about 20 variables already set, so this is OK. But now I've 50 links to various articles on my page. Those links are created dynamically using a mysql table, so I take the ArticleID. www.mysite.com/detail.php?ID=2 www.mysite.com/detail.php?ID=4 www.mysite.com/detail.php?ID=5 www.mysite.com/detail.php?ID=7 www.mysite.com/detail.php?ID=54 .... I'd like to avoid passing the ID in the URL. It's there any way to pass it in the SESSION variable. Javascript isn't possible, so I'd like to know if it's the only way to create the link. Or maybe must I use a FORM for every artivle ???? but with a link, I must use javascript.... Bob |
|
|||
|
Bob Bedford wrote:
> I'd like to avoid passing the ID in the URL. It's there any way to pass it > in the SESSION variable. To be able to store a value in the SESSION array, it has to be passed somehow from the browser to the server. Otherwise, you will not know what link the user clicked. There are 2 ways to do this - with HTTP get and post requests. So yes, you can store that variable in the session array, but it has to be passed to the server do so. Now, I don't know what your issue is: 1. you don't want to send that particular ID parameter; or 2. you don't want to send any parameters; or 3. you don't want to display any parameters in the browser location bar So, some ideas, respectively (if you don't want to use post or javascript): 1. Then send something else - title, some other temporary session-based reference, etc. 2. You can't not send anything because then you will not know what the user clicked; 3a. What you can do is send the ID to article-redirect.php that will set a session variable and then redirect to details.php. details.php will read that session variable and display the article without displaying the ID in the browser location bar. 3b. You can also send the article ID in the URL itself http://bogussite.com/1234/ where 1234 is the ID, and then use Apache's mod_rewrite (or a similar tool for other web servers) to translate to http://bogussite.com/details.php?ID=1234 So, the browser will see only the original URL, while the content will come from details.php. Anyway, I don't understand what you are trying to accomplish with this. You have to remember that (except in 3b) it will be harder for your users to bookmark your articles, send links to friends, etc. |