Click to See Complete Forum and Search --> : cookie help? 2 websites in one...
strBean
01-08-2006, 03:02 PM
Hi
My organization has decided that our website is aimed at 2 audiences with different interests and needs for information. I'm going to set up a splash page with probably 2 links to enter the site, one for professionals in our field and one for the general public. Once inside, the look and feel will be essentially the same, but the navigation menu will offer more stuff to the professional (which would be too much clutter for the layperson.)
I'm already starting and finishing each page with include files that set up the navigation menus, etc., so I'm thinking this won't be too hard to do, although I'm relatively new to web programming. I need some code that basically says:
if (this is a professional) {require "path/start_prof_page.inc";}
else {require "path/start_public_page.inc";}
I'm guessing that setting a cookie is the right way to do this. Am I on the right track, you think? I'm not too sharp on cookies yet, although I do use them a little already. Are there resources, tips on how to set up the session, that you can recommend?
thanks,
Sam
strBean
01-08-2006, 05:09 PM
Okay, I've done a little reading. It looks like my choices are to set a cookie, or propagate the SID through the URL. Although I use Get stmts for some other things, I think I prefer to keep the address bar mostly clean-looking for the user, so I'll go with a cookie.
Should I just set a cookie according to how the user enters the site, and then check the value of that cookie every time a new page loads, to determine which menu to display? I don't understand what session_start() does -- it seems that whether I propagate an ID through the URL or by setting a cookie, I can do that without a session. I guess I really don't get what a session is -- if I should be using session_start(), could someone give me a tip on how and why?
bokeh
01-08-2006, 05:45 PM
Splash pages are a pain and just lower your search engine rank! Not only that they are another hurdle between your users and what they want to buy. Personally I'd go for direct entry to the basic site with a link to the professional interface. If they click the link you could set a cookie or start a session but it is not really necessary.
Huevoos
01-08-2006, 09:22 PM
From my point of view you should not bake a cookie just to view the site like 1% of your visitors will reject cookies.
My simple approach would be a simple $_GET[user_type]
if ($_GET[user_type]=="pro"){
require "path/start_prof_page.inc";
}else{
require "path/start_public_page.inc";
}
a session is for a completely semi-unique web page
strBean
01-09-2006, 08:28 AM
From my point of view you should not bake a cookie just to view the site like 1% of your visitors will reject cookies.
My simple approach would be a simple $_GET[user_type]
Won't I have to pass along a Get stmt every time the user follows a link to another of my pages?
<a href="website/next_page.php?user_type=pro">Next Page</a>I'm not strictly against the idea, I was just thinking it wasn't very elegant for them to have that "?user_type=pro" following them everywhere they go...
bokeh
01-09-2006, 09:13 AM
The only time you need a query string is when your file system is chaotic. You should stick to a proper URL for all pages and leave the query string for it's correct purpose: transfering dynamic data. A query string is not needed to serve a static page; and for that matter nor is a cookie or a session.
strBean
01-09-2006, 09:29 AM
Okay, here's a little clarification. My goal here is serve up some pages to everybody, using this main navigation menu:
* home *
* about us *
* policy initiatives *
* links *
But if the user chooses to enter using the link "[name of discipline] professionals enter here", the menu will be:
* home *
* about us *
* policy initiatives *
* links *
* staff training*
* WIA core tracking *
* business services *
* directors' login *
Since I need all of the pages in the public section (there are 4 menu items, but there are more pages than that) to be displayed in the professional section also, I was thinking that I shouldn't set myself up to have to maintain 2 copies of each page. But it sounds like your suggestion is to keep everything for the professional in a separate folder, and send the professional over there...
Huevoos
01-09-2006, 10:23 AM
I wouldnt do what bokeh said, is the ideal case, but I'm just too lazy and is harder to mantain 2 pages with almost the exact same content, you could use this small thinghy for your links
function procheck(){
if($_GET[user_type]==pro)
return "user_type=pro";
}
and in every link you should put
<a href="next.php?<?=procheck()?>">NEXT PAGE</a>
chazzy
01-09-2006, 10:49 AM
I wouldnt do what bokeh said, is the ideal case, but I'm just too lazy and is harder to mantain 2 pages with almost the exact same content, you could use this small thinghy for your links
function procheck(){
if($_GET[user_type]==pro)
return "user_type=pro";
}
and in every link you should put
<a href="next.php?<?=procheck()?>">NEXT PAGE</a>
FYI I'd probably be able to hack into a system like that in a minute or 2.
strBean
01-09-2006, 10:57 AM
FYI I'd probably be able to hack into a system like that in a minute or 2.
You wouldn't want to; I wouldn't care.
Nothing secure about this. Both modes of entry are available to everyone, but if you enter as 'public', you are spared the clutter of a lot of technical info...
Thanks, huevoos, for the ideas.
I've opted to set a cookie if the user enters as 'public'. If their machine doesn't take the cookie, they'll have to put up with extra info and links, since the pro view will be the default...