Jump to content

Recommended Posts

Hi Friends,

 

Thanks for your initiatives to help me.

 

Here is my code:

<?
ob_start();
session_start();

if ($_GET['x']!="" && $_SESSION['custKey']=="")
{
$ky=$_GET['x'];
$_SESSION['custKey']=$ky;
}

if ($_GET['page'] == "login"){
include("login.php");
}
elseif ( $_GET['page'] == "cust_main" ) { 
include("custmain.php"); 
}

/*custmain.php*/
if (isset($_SESSION['custKey']))
	$cust_key=$_SESSION['custKey'];
else
	header("location:index.php?page=login&redirect=cust_main");


 

The above code works if i have the url as:

www.mydon.com/index.php?page=cust_main&x=5

 

immidiately after the above url is run if i remove x=5 and use only  www.mydon.com/index.php?page=cust_main it redirects me to login page.

 

Please let me know if am not clear in explaining you.

 

Thanks

 

 

 

Hi,

 

Thanks for your reply. Actually i feel this is not a problem with my code, i feel some config problem but unable to figure out what it is. This code works fine locally. But not in the server. Any how i tried what you said too , still it does not works.

 

Thanks

I checked php info, it seems to be fine. THats why confused.

 

session
Session Support 	enabled
Registered save handlers 	files user sqlite
Registered serializer handlers 	php php_binary wddx

Directive	Local Value	Master Value
session.auto_start	Off	Off
session.bug_compat_42	Off	Off
session.bug_compat_warn	On	On
session.cache_expire	180	180
session.cache_limiter	nocache	nocache
session.cookie_domain	no value	no value
session.cookie_lifetime	0	0
session.cookie_path	/	/
session.cookie_secure	Off	Off
session.entropy_file	no value	no value
session.entropy_length	0	0
session.gc_divisor	100	100
session.gc_maxlifetime	1440	1440
session.gc_probability	1	1
session.hash_bits_per_character	4	4
session.hash_function	0	0
session.name	PHPSESSID	PHPSESSID
session.referer_check	no value	no value
session.save_handler	files	files
session.save_path	/var/php_sessions	/var/php_sessions
session.serialize_handler	php	php
session.use_cookies	On	On
session.use_only_cookies	Off	Off
session.use_trans_sid	1	1

Well you need to view the page more than once, like take off your x=5 part. The first time the session will be empty, so there are no values. So if you add it at the bottom too, you should see the change, the session variables got assigned.

try setting to this session.use_only_cookies=0 if that doesn't work try making session_start(); the first thing after <?php

 

I know you said its set to off but try session.use_only_cookies=0 because i was getting Array() also and i changed that to 0 and everything works now

oh i meant where your session.use_only_cookies is in your php.ini change to session.use_only_cookies=0

 

i tried what you did above and it didn't work for me either

 

also make sure (in your php.ini file) the session.save_path is writable and readable for your server

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.