• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

Add custom text under order details on WooCommerce My account view order pages

Generate random username based on full name php

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

str_replace or preg_replace random number from string

How to convert time from one timezone to another in PHP

I want to display a sweetalert after the inserting of data in my database

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

Match single unknown parameter php (Morse-code Regex)

ORA-12546: TNS:permission denied error connection to remote oracle server

Hide email address with stars (*)

SQLSTATE[HY000]: General error: 1 table posts has no column named *

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given [duplicate]

could not find driver Debian SQL Server PHP

Laravel PHP: multiple project run at the same time [closed]

Redis Command To Sort Keys

About Contact Privacy policy Terms and conditions