everyone A very simple question, I'm working on a project web based The old way I used to direct different articles in my web projects is using PHP such
http://ift.tt/1A9UMHc
But I wanted to use something like
http://ift.tt/1JPv3DV instead of
php?id=232
But, the only close solution, I got to this is using hashtag
window.location.hash;
In case you don't know the above function it get the hashtag from browser header. And thus you can pass it to PHP using JS as well to set session that like
$_SESSION['articleid']="the hashtag"
Thus, when you open the page, it fist set the session, then load you the page Based on the article id
Ex.
Web.com/#1231231
Where javascript use window location hash and then pass it to PHP while loading
So, I have two questions
1- is using
window.location.hash
with PHP Session, is good practice for this case? And secure? 2- is there any alternative, better practice or approach for my case
I'm not sure what search question to type or words, to get information about this.
So, if any of you need to know why I don't just use
PHP?id=1223
Because, in my project the user is in index.html And every button he/she clicks , it load contents into index.html So, if the user open an article, the article is loaded into the same
index.html
But, then what if he/she want to share the article with another person Or if want to save it, for later?.
Thus, my solution was, to use
Window.Location.hash;
Read the hashtag, set the article id in session, load from article based on that session. If no hashtag, then just load the default
Please guide me. I see no problem with my approach.
Aucun commentaire:
Enregistrer un commentaire