jakebur01 Posted July 9, 2007 Share Posted July 9, 2007 I have been looking for something that will allow me to use a session only for part of a couple of pages. Example: I use session_start() at the top of all my pages, but on the categories page and home page I only want the session_start() to apply to the cart quanity and amount and not apply to all the rest of the links on the homepage. In other words, is their any way to turn off 'so to speak' the session after do_html_header() ? I don't want to destroy the session, I just want the session_start() to apply to only part of the page. session_start(); $catid = $_GET['catid']; $name = get_category_name($catid); do_html_header($name); $book_array = get_books($catid); display_books($book_array); Quote Link to comment https://forums.phpfreaks.com/topic/59082-solved-session-question/ Share on other sites More sharing options...
JasonLewis Posted July 9, 2007 Share Posted July 9, 2007 i did i search on php.net and found the following, maybe it applies, maybe it dosnt. http://au.php.net/manual/en/function.session-write-close.php Quote Link to comment https://forums.phpfreaks.com/topic/59082-solved-session-question/#findComment-293337 Share on other sites More sharing options...
jakebur01 Posted July 9, 2007 Author Share Posted July 9, 2007 I tried session_write_close() and it didn't work, I still had session id's in all my links below session_write_close() . I also tried session_destroy() and all it did was wipe out everything that I had in my cart. There has to be a function out there that will turn the session off for part of a page without destroying the session or loosing anything. Quote Link to comment https://forums.phpfreaks.com/topic/59082-solved-session-question/#findComment-293351 Share on other sites More sharing options...
JasonLewis Posted July 9, 2007 Share Posted July 9, 2007 why do you want to turn the session off anyway? just out of curiosity. Quote Link to comment https://forums.phpfreaks.com/topic/59082-solved-session-question/#findComment-293353 Share on other sites More sharing options...
jakebur01 Posted July 9, 2007 Author Share Posted July 9, 2007 So I won't have session id's attached to all my category and product links. I can solve this by just not doing session_start() on the homepage , but then my cart quanity and cart amount at the top of the page will all equal zero. So thats why I am wanting to keep the session for the top half and not have the session for the bottom half. Quote Link to comment https://forums.phpfreaks.com/topic/59082-solved-session-question/#findComment-293359 Share on other sites More sharing options...
trq Posted July 9, 2007 Share Posted July 9, 2007 So I won't have session id's attached to all my category and product links. Don't put session_start() in the files these links point to then. There is no function that does what you wish. Sessions simply do not work as you may think. Sessions apply to each request, not parts of scripts. Quote Link to comment https://forums.phpfreaks.com/topic/59082-solved-session-question/#findComment-293367 Share on other sites More sharing options...
JasonLewis Posted July 9, 2007 Share Posted July 9, 2007 i read somewhere that you can remove PHPSESSID from your urls by using .htaccess copy this into your .htaccess file, not sure if it will work though. you maybe able to edit your php.ini file... htaccess: php_flag session.use_trans_sid off give it a go, otherwise, i dunno. perhaps someone else can elaborate a bit further on this. Quote Link to comment https://forums.phpfreaks.com/topic/59082-solved-session-question/#findComment-293381 Share on other sites More sharing options...
per1os Posted July 9, 2007 Share Posted July 9, 2007 i read somewhere that you can remove PHPSESSID from your urls by using .htaccess copy this into your .htaccess file, not sure if it will work though. you maybe able to edit your php.ini file... htaccess: php_flag session.use_trans_sid off give it a go, otherwise, i dunno. perhaps someone else can elaborate a bit further on this. That is the best way to use sessions, it removes those annoying ids from the links and put the sessionid into a cookie. This will solve your problem of wanting to not use "session_start" as it would not append the session id to the urls. Quote Link to comment https://forums.phpfreaks.com/topic/59082-solved-session-question/#findComment-293385 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.