Sessions n Cookies problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
saily
Forum Newbie
Posts: 2
Joined: Mon Dec 13, 2010 2:45 am

Sessions n Cookies problem

Post by saily »

I want to use session variables to import objects from one page to another. i have successfully done this doing the following file1: insert.php

Code: Select all

<?
session_start();
$sam = "something";
$_SESSION['sam'] = $sam;
?>
file2: select.php

Code: Select all

<?
session_start();
$sam = $_SESSION['sam'];
But when i disable cookies, it doesn't work at all...i am wondering how to do i fix this problem?
Last edited by Benjamin on Mon Dec 13, 2010 8:02 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: Sessions n Cookies problem

Post by Apollo »

A user's session ID is usually stored (and thus passed on to the next page) in a cookie. So if you disable that, it doesn't work anymore :)

You can put the session ID in the url (see also the session.use_cookies and session.use_only_cookies settings), which will add a &sid=xxxx param to your URLs. Or invent your own way of saving session IDs :)

Then again, why would you disable cookies. It's completely normal for a website to require cookie support, at least any site that offers user settings or exchanges info between pages.
Post Reply